Recently, the boss order me to make sample app to persuade customer to sell the app.
So, There is some cases to play app without Internet.
In this case, I bring out image or music resource from drawable or assets folder.
1. How to get drawable's resourceID from drawable
val imgResourceId = context.resources.getIdentifier("album" + song.image.substringBefore("."), "drawable", context.packageName)
"album" + song.image.substringBefore(".") : drawable name except file extension.
"drawable" : resource type
context.packageName : package name
2. How to make drawable's Uri in Android
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()
댓글 없음:
댓글 쓰기