Comments (7)
It's not needed to add the app to the power-save exemption list, and it's probably a bad practice to encourage the user to do so for this kind of app.
However I noticed that on my device, even when granting the permission and using setExactAndAllowWhileIdle()
, the alarm may still be delayed by a minute or two when the device is in sleep mode, but it's good enough.
Regarding the fact that you're also using AlarmManager to update the schedule data in the background: the recommended API to do this nowadays is Jetpack WorkManager. It allows to set constraints for the job (for example a network connection is required), a retry policy, and more.
from eventfahrplan.
Hi there, here are some quick answers:
- In reality,
SCHEDULE_EXACT_ALARM
is a normal permission and not a runtime permission, so adding it to the manifest is enough to obtain it. However, obtaining the permission only does half of the job, as it only enables the "Alarms and Reminders" option panel in the system app settings. The second part of the job is to ask the user to go check the box in that panel, and as a shortcut you can launch theACTION_REQUEST_SCHEDULE_EXACT_ALARM
intent. - I didn't notice that issue, I receive
RESULT_OK
if the box is checked when returning to the app. Make sure you pass"package:${BuildConfig.APPLICATION_ID}"
as uri data in your intent in addition to the action (assuming you use BuildConfig and are in your app module, otherwise you can also usecontext.packageName
) - I'm afraid this screen will always be shown using the system language because the user is actually leaving your app to be redirected to a system settings screen.
from eventfahrplan.
-
Not sure what goes wrong here. I am using the following intent:
val intent = Intent(ACTION_REQUEST_SCHEDULE_EXACT_ALARM) .setData("package:${BuildConfig.APPLICATION_ID}".toUri()) scheduleExactAlarmsPermissionRequestLauncher.launch(intent)
Functionality-wise everything works. So this can be fixed later, too. I now merge the branch.
Thank you again for bringing this up!
from eventfahrplan.
Thank you for reporting this issue and the effort of providing both the detailed analysis and the implementation reference!
It is indeed something that should be address as soon as possible (speaking of alarms ... smirk). I have seen the announcements before. I haven't come around to look into the topic for a while, though.
Power-save exemption
Apps targeting Build.VERSION_CODES#S or higher can schedule exact alarms only if they have the Manifest.permission#SCHEDULE_EXACT_ALARM permission or they are on the device's power-save exemption list. These apps can also start Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM to request this permission from the user.
Source: https://developer.android.com/reference/android/app/AlarmManager#canScheduleExactAlarms()
Do you think requesting to be on the "device's power-save exemption list" is also required to have alarms being fired on time? Also PowerManager#isIgnoringBatteryOptimizations
is mentioned on the page.
Docs
Here is a few more links to the docs for later reference:
- Android 12 / behavior changes: Exact alarm permission
- Android 13 / behavior changes: New permission to use exact alarms
- Android 14 / behavior changes: Schedule exact alarms are denied by default
Notes
has to be separated from the change to use exact alarms is separated an uses AlarmManager#setInexactRepeating
.
from eventfahrplan.
Looking into the topic I noticed a few questions / shortcomings:
- Why can I not invoke
permissionRequestLauncher.launch(SCHEDULE_EXACT_ALARM)
like forPOST_NOTIFICATIONS
? And why is there no warning that it is wrong if I do anyway? - Once I granted the system permission screen with
ACTION_REQUEST_SCHEDULE_EXACT_ALARM
and resume my app theresultCode
isRESULT_CANCELED
and tell nothing about whether the permission was granted or not. Isn't that very inconvinient? - When I launch the system permission screen from an app running with a different language (e.g. German) than the system language (e.g. English) then the system permission screen is shown in the system language (e.g. English). That seems to be not very helpful for users.
@cbeyls Did you notice these too? Any other?
from eventfahrplan.
Maybe your issue is hardware-related? I tested my implementation on the emulator and on a Pixel 4a.
You can always test AlarmManager.canScheduleExactAlarms()
instead when the activity result arrives.
from eventfahrplan.
I tested it on various devices and emulators - see: #614
Yes, I also check with canScheduleExactAlarms()
, see:
from eventfahrplan.
Related Issues (20)
- Hard crash on startup `Too small number of days` HOT 4
- Design of an EventFahrplan logo HOT 2
- Design static graphics for empty screens HOT 6
- Rethink user flow and positioning of interaction elements HOT 1
- Layout and design of a session card HOT 1
- Allow to search for an event HOT 1
- Allow to list events by track (security, science, ...) instead of day HOT 1
- 37C3 Fahrplan App crashes when Engelsystem-JSON-URL is entered HOT 10
- iOS Version 16.7.4 canβt install app from App Store HOT 2
- Timeline no longer shown if time is past 00:00 in the current day HOT 1
- ssl fahrplan.events.ccc.de not verified: certificate HOT 3
- Add setting to define app orientation (mainly landscape) HOT 6
- Share to JSON seems to be buggy? Sharing wrong information. HOT 5
- Multiple schedule updates (especially "0 added, 0 changed, 0 removed" pseudo-changesets)
- Use targetSdk 34, Android 14
- Adjust App year to 2024 HOT 1
- Timezone setting not correct HOT 3
- Migrate Session class from Java to Kotlin
- Automated CD HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventfahrplan.