first check if element exist, then access it
This commit is contained in:
parent
39be1bb4c7
commit
b2d2f462f6
1 changed files with 3 additions and 3 deletions
|
@ -244,14 +244,14 @@ public class MainActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){
|
if (permissions.length != 0) {
|
||||||
if(permissions.length != 0){
|
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case CASE_STORAGE:
|
case CASE_STORAGE:
|
||||||
//show dialog after permission is granted
|
//show dialog after permission is granted
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||||
alert.setMessage(R.string.alert_dialog_storage_permission_text);
|
alert.setMessage(R.string.alert_dialog_storage_permission_text);
|
||||||
alert.setPositiveButton(R.string.ok,null);
|
alert.setPositiveButton(R.string.ok, null);
|
||||||
alert.show();
|
alert.show();
|
||||||
break;
|
break;
|
||||||
case CASE_SMS:
|
case CASE_SMS:
|
||||||
|
|
Loading…
Reference in a new issue