Skip to content

Commit

Permalink
Move request for microphone permission to onCreate
Browse files Browse the repository at this point in the history
This request can cause issues if the user denies the microphone permission.
Calling requestPermissions causes GrantPermissionsActivity to be launched.
Citra's MainActivity will pause. GrantPermissionsActivity will immediately
finish as the user has already denied the permission. Citra's MainActivity then
gets resumed and then tries to request the permission again forming a loop.
  • Loading branch information
gyroninja committed Jan 25, 2024
1 parent dd5041f commit ce640bb
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ protected void onCreate(Bundle savedInstanceState) {
requestNotificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
}
}
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
// Request permission if it's not granted
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, 0);
}
// Check for the TWO_INSTANCES string extra
if (getIntent().getBooleanExtra(VrActivity.EXTRA_ERROR_TWO_INSTANCES, false)) {
Log.error("Error: two instances of CitraVr::VrActivity were running at the same time!");
Expand Down Expand Up @@ -214,10 +218,6 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
@Override
protected void onResume() {
super.onResume();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
// Request permission if it's not granted
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, 0);
}
mPresenter.addDirIfNeeded(new AddDirectoryHelper(this));

ThemeUtil.setSystemBarMode(this, ThemeUtil.getIsLightMode(getResources()));
Expand Down

0 comments on commit ce640bb

Please sign in to comment.