如何获取DrawableImage Android的URI

时间:2015-05-19 12:35:17

标签: android

Drawable appIcon = packageManager
        .getApplicationIcon(packageInfo.applicationInfo);

如何获取appIcon的uri?

2 个答案:

答案 0 :(得分:0)

Uri uri = Uri.parse("android.resource://your.package.here/drawable/image_name");
InputStream stream = getContentResolver().openInputStream(uri);

使用ContentResolver打开资源URI

答案 1 :(得分:0)

格式为:

"android.resource://[package]/[res id]"

[package] is your package name

[res id] is value of the resource ID, e.g. R.drawable.sample_1

to stitch it together, use

Uri path = Uri.parse("android.resource://your.package.name/" + R.drawable.sample_1);