diff --git a/src/android/LocalNotification.java b/src/android/LocalNotification.java index 7b92a178b..725f339e1 100644 --- a/src/android/LocalNotification.java +++ b/src/android/LocalNotification.java @@ -23,8 +23,13 @@ import android.annotation.SuppressLint; import android.app.Activity; +import android.app.AlarmManager; import android.app.KeyguardManager; import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.provider.Settings; import android.util.Pair; import android.view.View; @@ -90,6 +95,14 @@ public void initialize (CordovaInterface cordova, CordovaWebView webView) { public void onResume (boolean multitasking) { super.onResume(multitasking); deviceready(); + + Context context = cordova.getActivity().getApplicationContext(); + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms()) { + Intent intent = new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM); + intent.setData(Uri.fromParts("package", context.getPackageName(), null)); + cordova.getActivity().startActivity(intent); + } } /**