Android 6 で許可を取るには:-
public void android6permission{
String[] permissions = {
"android.permission.CAMERA",
"android.hardware.camera",
"android.permission.ACCESS_COARSE_LOCATION",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE"
};
requestPermissions(permissions, 122323);
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case 122323: {
if (grantResults[0] ==
PackageManager.PERMISSION_GRANTED){
// Do task
} else {
Toast.makeText(getApplicationContext(),"Access denied",Toast.LENGTH_SHORT).show();
// permission denied, boo! Disable the
// functionality that depends on this permission.
}
return;
}
}
}
onCreate でメソッド android6permission() を実行するだけです