Hi Everyone, I'm working on implementing media fil...
# android
w
Hi Everyone, I'm working on implementing media file downloads using Custom Tabs and I've encountered an issue in the android app. Specifically, for PDF or DOCX files, I need to download them before they can be opened. However, when
launchUrl
is called, if the file is already present, it displays "Download Pending" indefinitely. The issue is resolved by deleting the existing file from storage, allowing the download to proceed. This problem doesn’t occur with photos and videos. I'm attaching the code for reference.
not kotlin but kotlin colored 2
Copy code
private fun openInCustomTab(url: String) {
    val customTabsIntentBuilder = CustomTabsIntent.Builder()

    customTabsIntentBuilder.setToolbarColor(
        ContextCompat.getColor(this, R.color.colorPrimary)
    )

    customTabsIntentBuilder.setShowTitle(true)

    customTabsIntentBuilder.setStartAnimations(
        this,
        android.R.anim.slide_in_left,
        android.R.anim.slide_out_right
    )
    customTabsIntentBuilder.setExitAnimations(
        this,
        android.R.anim.slide_in_left,
        android.R.anim.slide_out_right
    )

    val customTabsIntent = customTabsIntentBuilder.build()

    customTabsIntent.launchUrl(this, Uri.parse(url))
}
s
Try asking this question in one of these places
this channel is about Kotlin usage in Android, not general Android questions. you'll get better help there.
👍 1