我正在为Android开发一种媒体播放器,想要获得专辑封面,并使用此代码。
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);
但是我得到FileNotfoundExeption,并且艺术品设置为null(
这是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)
答案 0 :(得分:0)
我遇到similar problem时遇到问题所以我可以建议一些检查: