Commit 83e7ac84 authored by Schoumi's avatar Schoumi

Fix crash onPermissionResult before any permission request

parent ed9f00ba
Pipeline #88 passed with stage
in 15 seconds
......@@ -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();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment