-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle exact alarms on android >= 14 #19
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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()) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? Do we need the second condition? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
Intent intent = new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM); | ||||||
intent.setData(Uri.fromParts("package", context.getPackageName(), null)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should bind the intent to the app |
||||||
cordova.getActivity().startActivity(intent); | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not use a runtime request permission instead of navigating to the settings page? Permissions like for pictures and Geo-location at the start of the app?