Browse Source

Fix crash onPermissionResult before any permission request

tags/release-v3.3
Schoumi 2 years ago
parent
commit
83e7ac84fc
2 changed files with 4 additions and 4 deletions
  1. +2
    -2
      app/build.gradle
  2. +2
    -2
      app/src/main/java/fr/mobdev/blooddonation/activity/MainActivity.java

+ 2
- 2
app/build.gradle View File

@@ -7,8 +7,8 @@ android {
applicationId "fr.mobdev.blooddonation"
minSdkVersion 17
targetSdkVersion 26
versionCode = 10
versionName = "3.2"
versionCode = 11
versionName = "3.3"
}
buildTypes {
release {

+ 2
- 2
app/src/main/java/fr/mobdev/blooddonation/activity/MainActivity.java View File

@@ -134,14 +134,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if(requestCode == 1 && (grantResults[0] == PackageManager.PERMISSION_GRANTED || grantResults[1] == PackageManager.PERMISSION_GRANTED)) {
if(requestCode == 1 && grantResults.length == 2 && (grantResults[0] == PackageManager.PERMISSION_GRANTED || grantResults[1] == PackageManager.PERMISSION_GRANTED)) {
FragmentManager manager = getFragmentManager();
Fragment frag = manager.findFragmentById(R.id.fragment_container);
if(frag instanceof MapsFragment) {
((MapsFragment)frag).startUpdateLocations();
}
}
if(requestCode == 2 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
if(requestCode == 2 && grantResults.length == 1 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,R.string.need_write,Toast.LENGTH_LONG).show();
}
}

Loading…
Cancel
Save