Skip to content

Instantly share code, notes, and snippets.

@sahildev001
Created June 16, 2022 10:08
Show Gist options
  • Save sahildev001/1692ab4d22c8f5a8cd3d363c9ab9b79d to your computer and use it in GitHub Desktop.
Save sahildev001/1692ab4d22c8f5a8cd3d363c9ab9b79d to your computer and use it in GitHub Desktop.
get image uri from drawable android
private fun changedrawabletoUri(resourceId :Int):Uri{
        val imageUri = (Uri.Builder())
                .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
            .authority(resources.getResourcePackageName(resourceId))
            .appendPath(resources.getResourceTypeName(resourceId))
            .appendPath(resources.getResourceEntryName(resourceId))
            .build()
        return imageUri
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment