Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private final static int REQUEST_CODE = 101;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_overlay);
- ButterKnife.bind(this);
- checkDrawOverlayPermission();
- }
- private void checkDrawOverlayPermission() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- if (!Settings.canDrawOverlays(this)) {
- Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + this.getPackageName()));
- startActivityForResult(intent, REQUEST_CODE);
- finish();
- }
- }
- }
- @Override
- public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == REQUEST_CODE) {
- Toast.makeText(this, "Ok", Toast.LENGTH_SHORT).show();
- Intent intent = new Intent(getApplicationContext(), MainActivity.class);
- startActivity(intent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement