Get Uri from android drawable resource
1. What I have in my android drawable folder
2. Get Uri from drawable
val imgResourceId = context.resources.getIdentifier("album" + song.image.substringBefore("."), "drawable", context.packageName)
val imageUri = Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(context.resources.getResourcePackageName(imgResourceId))
.appendPath(context.resources.getResourceTypeName(imgResourceId))
.appendPath(context.resources.getResourceEntryName(imgResourceId))
.build()
3. Result
android.resource://net.twobeone.battlesinger/drawable/album00290
android.resource://net.twobeone.battlesinger/drawable/album01468
android.resource://net.twobeone.battlesinger/drawable/album49492
댓글 없음:
댓글 쓰기