First, I believe this is the same issue as described by this SO post. I want to provide more details and be as specific as possible in the hope that some guru will come up with an elegant solution. This happens with Android 5.1

The following code

startActivityForResult(myMediaProjectionManager.createScreenCaptureIntent(), REQUEST_CODE_SCREEN_RECORDING);

will show the following prompt to the user:

enter image description here

If the user does not select "Don't show again", everything will work exactly as expected. Unfortunately, if "Don't show again" is selected, the same code will lead to the following prompt from the next run: enter image description here

The device will go to the lock screen after the prompt.

Could anyone confirm this is caused by a system bug and offer a remedy without asking the user to avoid selecting "Don't show again"?

1

There are 1 best solutions below

7
CommonsWare On BEST ANSWER

Could anyone confirm this is caused by a system bug

If you are seeing the same Java stack trace as is reported in this issue, then yes, this would appear to have been a system bug.

and offer a remedy without asking the user to avoid selecting "Don't show again"?

Ask the user to upgrade their device. Apparently, this was fixed in 5.1.1.

Or, do not use MediaProjectionManager. The problem is not in your app, and so there is nothing that you can do to change the behavior.