我有一个Android应用程序名称调用者屏幕更改程序。当有人打电话时,屏幕将改变。 我尝试了数百种方法来解决覆盖其他应用程序的权限问题,但仍然显示错误和权限无法解决。
我的代码:
public void permit() {
if (!Settings.canDrawOverlays(MainActivity.this)) {
final Dialog drawOverDialog = new Dialog(MainActivity.this);
drawOverDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
drawOverDialog.setContentView(R.layout.draw_over_apps_dialog);
Button btnOk = (Button) drawOverDialog.findViewById(R.id.btnOk);
btnOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = null;
intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + MainActivity.this.getPackageName()));
((Activity) MainActivity.this).startActivityForResult(intent, 0);
drawOverDialog.dismiss();
}
});
Objects.requireNonNull(drawOverDialog.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
drawOverDialog.show();
// ((Activity) getApplicationContext()).finish();
}
}