15 package com.introlab.rtabmap;
17 import android.Manifest;
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.content.pm.PackageManager;
22 import android.net.Uri;
23 import android.provider.Settings;
24 import android.support.v4.app.ActivityCompat;
25 import android.support.v4.content.ContextCompat;
38 public static boolean hasPermission(Activity activity, String permission) {
39 return ContextCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_GRANTED;
45 if (permission == Manifest.permission.CAMERA) {
47 }
else if(permission == Manifest.permission.READ_EXTERNAL_STORAGE) {
49 }
else if(permission == Manifest.permission.WRITE_EXTERNAL_STORAGE) {
51 }
else if(permission == Manifest.permission.INTERNET) {
53 }
else if(permission == Manifest.permission.ACCESS_NETWORK_STATE) {
55 }
else if(permission == Manifest.permission.ACCESS_FINE_LOCATION) {
57 }
else if(permission == Manifest.permission.ACCESS_WIFI_STATE) {
62 ActivityCompat.requestPermissions(
63 activity,
new String[] {permission}, requestCode);
69 return ActivityCompat.shouldShowRequestPermissionRationale(activity, permission);
74 Intent intent =
new Intent();
75 intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
76 intent.setData(Uri.fromParts(
"package", activity.getPackageName(), null));
77 activity.startActivity(intent);
static boolean hasPermission(Activity activity, String permission)
static final int INTERNET_CODE
static void requestPermission(Activity activity, String permission)
static final int ACCESS_FINE_LOCATION_CODE
static final int ACCESS_WIFI_STATE_CODE
static final int ACCESS_NETWORK_STATE_CODE
static boolean shouldShowRequestPermissionRationale(Activity activity, String permission)
static final int CAMERA_CODE
static final int WRITE_EXTERNAL_STORAGE_CODE
static void launchPermissionSettings(Activity activity)
static final int READ_EXTERNAL_STORAGE_CODE