Skip to content

Commit 3993724

Browse files
committed
put permission message in a static field
1 parent 4cc3b33 commit 3993724

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

studio/apps/arscene/src/main/java/arscene/MainActivity.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
public class MainActivity extends AppCompatActivity {
2121
private static final int CAMERA_PERMISSION_CODE = 0;
2222
private static final String CAMERA_PERMISSION = Manifest.permission.CAMERA;
23+
private static final String CAMERA_PERMISSION_MESSAGE = "Camera permission is needed to use AR";
2324

2425
private PApplet sketch;
2526

@@ -45,10 +46,8 @@ protected void onResume() {
4546
@Override
4647
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
4748
if (!hasCameraPermission()) {
48-
Toast.makeText(this, "Camera permission is needed to use AR", Toast.LENGTH_LONG)
49-
.show();
49+
Toast.makeText(this, CAMERA_PERMISSION_MESSAGE, Toast.LENGTH_LONG).show();
5050
if (!shouldShowRequestPermissionRationale()) {
51-
// Permission denied with checking "Do not ask again".
5251
launchPermissionSettings();
5352
}
5453
finish();
@@ -89,17 +88,14 @@ private void requestCameraPermission() {
8988
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, CAMERA_PERMISSION_CODE);
9089
}
9190

92-
/** Check to see if we need to show the rationale for this permission. */
9391
private boolean shouldShowRequestPermissionRationale() {
9492
return ActivityCompat.shouldShowRequestPermissionRationale(this, CAMERA_PERMISSION);
9593
}
9694

97-
/** Launch Application Setting to grant permission. */
9895
private void launchPermissionSettings() {
9996
Intent intent = new Intent();
10097
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
10198
intent.setData(Uri.fromParts("package", this.getPackageName(), null));
10299
this.startActivity(intent);
103100
}
104-
105101
}

0 commit comments

Comments
 (0)