diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 84f297c0ae..c3231814db 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -1,6 +1,5 @@ package info.nightscout.androidaps; -import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; @@ -72,19 +71,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe menuButton = (ImageButton) findViewById(R.id.overview_menuButton); menuButton.setOnClickListener(this); - checkEula(); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - AndroidPermission.askForPermission(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE); - } - AndroidPermission.askForBatteryOptimizationPermission(this); - doMigrations(); - if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { Intent intent = new Intent(this, SetupWizardActivity.class); startActivity(intent); } + checkEula(); + AndroidPermission.askForStoragePermission(this); + AndroidPermission.askForBatteryOptimizationPermission(this); + doMigrations(); + if (Config.logFunctionCalls) log.debug("onCreate"); diff --git a/app/src/main/java/info/nightscout/utils/AndroidPermission.java b/app/src/main/java/info/nightscout/utils/AndroidPermission.java index c0ce505e9b..45db300cef 100644 --- a/app/src/main/java/info/nightscout/utils/AndroidPermission.java +++ b/app/src/main/java/info/nightscout/utils/AndroidPermission.java @@ -60,6 +60,13 @@ public class AndroidPermission { } } + public static synchronized void askForStoragePermission(Activity activity) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE); + } + } + public static synchronized void askForLocationPermissions(Activity activity) { if (askForLocation) { //only when settings were changed an MainActivity resumes. askForLocation = false;