// Callback with the request from calling requestPermissions(...)
 @Override
 public void onRequestPermissionsResult(
     int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
   // Make sure it's our original READ_CONTACTS request
   if (requestCode == INTERNET_PERMISSION) {
     if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
       Toast.makeText(this, "Internet permission granted", Toast.LENGTH_SHORT).show();
     } else {
       Toast.makeText(this, "Inter permission denied", Toast.LENGTH_SHORT).show();
     }
   } else {
     super.onRequestPermissionsResult(requestCode, permissions, grantResults);
   }
 }
Пример #2
0
 @Override
 public void onRequestPermissionsResult(
     int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
   super.onRequestPermissionsResult(requestCode, permissions, grantResults);
   if (grantResults.length <= 0) {
     return;
   }
   switch (requestCode) {
     case Constant.LOCATION_STATE:
       {
         if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
           Toast.makeText(AppSignActivity.this, "成功获取定位权限", Toast.LENGTH_SHORT).show();
           getLocation();
         } else if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
           Toast.makeText(AppSignActivity.this, "网络定位权限被禁用", Toast.LENGTH_SHORT).show();
         }
       }
       break;
   }
 }