Viewing PDF via startActivity on Android R not working

Viewed 825

I've updated the codebase to be compatible with Android R, this works on SDK <= 29, just not on R

It isn't throwing an error, and the activity is starting, but the activity (PDF Viewer) is closing immediately and resuming the mainActivity

        val intent= Intent(Intent.ACTION_VIEW)
        intent.setDataAndType(uri, attachmentMimeType)
        intent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK
        try {
            context.startActivity(intent)
        } catch (e: ActivityNotFoundException) {
            Toast.makeText(
                context,
                "Unable to open file",
                Toast.LENGTH_LONG
            ).show()
        }

Has there been any changes for this situation on the new Android R preview?

0 Answers
Related