2

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?

ADM
  • 20,406
  • 11
  • 52
  • 83
Brandon
  • 1,158
  • 3
  • 12
  • 22
  • Use Logcat to examine the stack trace associated with your crash. Perhaps you do not have rights to `uri`. – CommonsWare May 08 '20 at 11:35
  • Implementing a ContentProvider solved this problem for me ( you can check the solution by Big McLargeHuge here : https://stackoverflow.com/questions/17453105/android-open-pdf-file ) – PayToPwn May 27 '20 at 10:49
  • This works fine on Android 11 beta 1, so apparently this was fixed. – M66B Jun 14 '20 at 07:59

0 Answers0