如何获取DrawableImage Android的URI

如何获取DrawableImage Android的URI,android,Android,如何获取appIcon的uri Drawable appIcon = packageManager .getApplicationIcon(packageInfo.applicationInfo); 使用ContentResolver打开资源URI格式为: Uri uri = Uri.parse("android.resource://your.package.here/drawable/image_name"); InputStream stream = getContent

如何获取appIcon的uri

Drawable appIcon = packageManager
        .getApplicationIcon(packageInfo.applicationInfo);
使用ContentResolver打开资源URI

格式为:

Uri uri = Uri.parse("android.resource://your.package.here/drawable/image_name");
InputStream stream = getContentResolver().openInputStream(uri);
"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);