I am developing a sort of media player for android, want to get Album Art, and use this code.
Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
Uri uri = ContentUris.withAppendedId(sArtworkUri, album_id);
ContentResolver res = context.getContentResolver();
try {
in = res.openInputStream(uri);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Bitmap artwork = BitmapFactory.decodeStream(in);
But I get FileNotfoundExeption, and artwork sets to null(
Here is the LogCat
09-06 14:55:56.713: ERROR/MetadataRetrieverClient(34): failed to extract an album art
09-06 14:55:56.723: WARN/System.err(536): java.io.FileNotFoundException: No entry for content://media/external/audio/albumart/1
09-06 14:55:56.733: WARN/System.err(536): at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:123)
09-06 14:55:56.733: WARN/System.err(536): at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:538)
09-06 14:55:56.733: WARN/System.err(536): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:484)
09-06 14:55:56.733: WARN/System.err(536): at android.content.ContentResolver.openInputStream(ContentResolver.java:319)
09-06 14:55:56.733: WARN/System.err(536): at player.org.Progress.onCreate(Progress.java:92)
09-06 14:55:56.733: WARN/System.err(536): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-06 14:55:56.733: WARN/System.err(536): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-06 14:55:56.733: WARN/System.err(536): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-06 14:55:56.743: WARN/System.err(536): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-06 14:55:56.743: WARN/System.err(536): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-06 14:55:56.743: WARN/System.err(536): at android.os.Handler.dispatchMessage(Handler.java:99)
09-06 14:55:56.743: WARN/System.err(536): at android.os.开发者_开发知识库Looper.loop(Looper.java:123)
09-06 14:55:56.743: WARN/System.err(536): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-06 14:55:56.743: WARN/System.err(536): at java.lang.reflect.Method.invokeNative(Native Method)
09-06 14:55:56.743: WARN/System.err(536): at java.lang.reflect.Method.invoke(Method.java:507)
09-06 14:55:56.743: WARN/System.err(536): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-06 14:55:56.743: WARN/System.err(536): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-06 14:55:56.753: WARN/System.err(536): at dalvik.system.NativeStart.main(Native Method)
精彩评论