解决方案 »
- 全志A10的uboot启动不了," not definedot_normal
- 如何让Widget程序一运行出现在桌面上
- objectc的编译程序
- 初学者请教个问题
- Android SurfaceView闪烁问题
- 如何向一个android应用程序发送通知?
- opencore里面如何出LOGV!?
- 新手菜鸟求助,关于Adapter
- 如何在 Android 下 实现 非 root 权限的 traceroute
- requestPermissions如何同步回调onRequestPermissionsResult?
- 求解 关于oracle数据读取的问题????
- 据说安卓程序大多免费,各位都是做什么程序的
long albumid) {
Uri sArtworkUri = Uri
.parse("content://media/external/audio/albumart");
Bitmap bm = null;
// 专辑id和歌曲id小于0说明没有专辑、歌曲,并抛出异常
if (albumid < 0 && songid < 0) {
throw new IllegalArgumentException(
"Must specify an album or a song id");
}
try {
if (albumid < 0) {
Uri uri = Uri.parse("content://media/external/audio/media/"
+ songid + "/albumart");
InputStream is= context.getContentResolver().openInputStream(uri);
if (is != null) {
bm=BitmapFactory.decodeStream(is);
}
} else {
Uri uri = ContentUris.withAppendedId(sArtworkUri, albumid);
InputStream is= context.getContentResolver().openInputStream(uri);
if (is != null) {
bm=BitmapFactory.decodeStream(is);
} else {
return null;
}
}
} catch (FileNotFoundException ex) {
}
return bm;
}
songid 和albumid 从Cursor cursor1 = context.getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null,
null);从这个表里面取得字段为MediaStore.Audio.Media._ID,,MediaStore.Audio.Media.ALBUM_ID。祝你好运!
.getColumnIndex(MediaStore.Audio.Media._ID));
int albumid = cursor.getInt(cursor
.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));