我正在尝试处理新的Android Lollipop MediaProjection API。
我发现(至少在我的股票三星Galaxy S4 jfltexx上)当我开始获得捕获屏幕的权限(ProjectionManager.createScreenCaptureIntent()
)的意图时,我在{{我没有获得结果1}}除非我已经检查过了“不要再问”#34;在前面的尝试...
onActivityResult
结果处理:
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);
}
...
}
权限对话框显示效果很好,但我的活动被隐藏了,它永远不会转到@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println("RebootActivity.onActivityResult(" + requestCode + "," + resultCode + ", data)");
}
。
知道出了什么问题?
答案 0 :(得分:-1)
您是否尝试过这样做:请参见完整示例android-ScreenCapture
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_MEDIA_PROJECTION) {
if (resultCode != Activity.RESULT_OK) {
Log.i(TAG, "User cancelled");
Toast.makeText(getActivity(), R.string.user_cancelled, Toast.LENGTH_SHORT).show();
return;
}
Activity activity = getActivity();
if (activity == null) {
return;
}
Log.i(TAG, "Starting screen capture");
mResultCode = resultCode;
mResultData = data;
setUpMediaProjection();
setUpVirtualDisplay();
}
}
希望它会对你有所帮助。