I'm trying to deal with the new Android Lollipop MediaProjection API.
I have found that (at least on my stock Samsung Galaxy S4 jfltexx) when I start the intent to get permission to capture the screen (ProjectionManager.createScreenCaptureIntent()
), I won't have a result in onActivityResult
unless I have checked "Don't ask again" on the preceding try ...
private static final int ALLOW_SCREENSHOT_REQ = 102;
{
...
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
System.out.println("request permission");
startActivityForResult(mProjectionManager.createScreenCaptureIntent(), ALLOW_SCREENSHOT_REQ);
}
...
}
And the result handling:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println("RebootActivity.onActivityResult(" + requestCode + "," + resultCode + ", data)");
}
The permission dialog is showing well, but my activity gets hidden and it never goes to onActivityResult
.
Any idea of what's going wrong?