반응형
ActivityCompat.requestPermissions(this,new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 1);
int permissionCheck = ContextCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION);
System.out.println("[DEBUG]ActivityWorkMain permissionCheck="+permissionCheck);
private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(),
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
android.Manifest.permission.ACCESS_FINE_LOCATION))) {
} else {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION
},
REQUEST_PERMISSIONS);
}
} else {
boolean_permission = true;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case REQUEST_PERMISSIONS: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
boolean_permission = true;
} else {
Toast.makeText(getApplicationContext(), "Please allow the permission",
Toast.LENGTH_LONG).show();
}
}
}
}
반응형
'모바일개발(Mobile Dev) > 안드로이드개발(Android)' 카테고리의 다른 글
Invalid_grant (0) | 2017.09.02 |
---|---|
everything for facebook login in android (0) | 2017.08.20 |
to move location at a center of camera (0) | 2017.08.07 |
how to use moving on current location (0) | 2017.08.06 |
service template in android (0) | 2017.07.27 |