简体   繁体   中英

Conitnue after asking for permission Android Studio

CODE:

ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1);

driverList = new ArrayList < > ();
file = new File(Environment.getExternalStorageDirectory().toString() + "/drivers.json");

if (!file.exists()) {
   try {
      file.createNewFile();
      ServerTask st = new ServerTask("2019", true);
      st.execute();
   } catch (IOException e) {
      e.printStackTrace();
   }
} else {
   load();
}

So I have this code and after I have installed the app and I was asked for the permission the App doesn't continue. I always accept the permission

The code you have provided here only states the checks on the required permissions anda call to request them. Please post the code for requestPermissions method

Also try the following

  1. You must implement onRequestPermissionResult method in your activity
  2. In that method you verify that the permissions are now granted
  3. Finally perform the action you need to achieve.

If you have already done that then pls post that code snippet here.

Refer to this documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM