Fix crash onPermissionResult before any permission request

master release-v3.3
Schoumi 6 years ago
parent ed9f00bab2
commit 83e7ac84fc

@ -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 {

@ -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