This popup is caused by the manifest.PERMISSION.SYSTEM_ALERT_WINDOW declaration declared by the manifest.
These are 3 categories of permissions that a developer should know about:
Normal resolution - do nothing with them, just declare it in the Manifesto
Vulnerable permissions - declare in the manifest and request permission for the first time. They can be changed through the system settings.
Over dangerous permissions: SYSTEM_ALERT_WINDOW and WRITE_SETTINGS fall into this category. They should be provided, but not displayed in the system settings. To request it, you are not using the standard method (int checkSelfPermission (String permission)), but you should check Settings.canDrawOverlays () or Settings.System.canWrite () accordingly, and if you do not, you will get an exception, for example
Cannot add window android.view.ViewRootImpl$W@1de28ad - permission denied for this window type
1-Request this permission yourself in your code, as follows:
public class MainActivity extends AppCompatActivity { public final static int REQUEST_CODE = 10000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (checkDrawOverlayPermission()) { Toast.makeText(this, "Permission granted", Toast.LENGTH_SHORT).show(); } } public boolean checkDrawOverlayPermission() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return true; } if (!Settings.canDrawOverlays(this)) { Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); startActivityForResult(intent, REQUEST_CODE); return false; } else { return true; } } @Override @TargetApi(Build.VERSION_CODES.M) protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE) { if (Settings.canDrawOverlays(this)) { Toast.makeText(this, "Permission granted", Toast.LENGTH_SHORT).show(); } } }
Ghulam Qadir May 22 '19 at 8:32 a.m. 2019-05-22 08:32
source share