Wednesday, July 7, 2010

[android-developers] Add Media Files to Library in Froyo

I have develop and app that downloads music files and should add them
to the music library. I use the following class to do this:

public class MediaScannerNotifier implements
MediaScannerConnectionClient {

private Context mContext;
private MediaScannerConnection mConnection;
private String mPath;
private String mMimeType;

public MediaScannerNotifier(Context context, String path, String
mimeType) {
mContext = context;
mPath = path;
mMimeType = mimeType;
mConnection = new MediaScannerConnection(context, this);
mConnection.connect();
}

public void onMediaScannerConnected() {
Log.e("SCANNER","SCAN CONNECTED");
mConnection.scanFile(mPath, mMimeType);
}

public void onScanCompleted(String path, Uri uri) {
Log.e("SCANNER","SCAN COMPLETED "+path+" "+uri);
mConnection.disconnect();
mContext = null;
}
}

Everything works ok with android 2.1 and below. But, in android 2.2,
the media files do not get added to my music library. :( I know there
were some changes in froyo API for music scanning, but I am unsure why
the above no longer works.

By the way, everything seems to scan fine - i.e. I get ok log messages
- E/SCANNER ( 339): SCAN COMPLETED /sdcard/EMusic/Josh Woodward/
Breadcrumbs/TheVoices.mp3 content://media/internal/audio/media/4

Any idea on what to change to make media scanning work again in froyo?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate