Blog Infos
Author
Published
Topics
,
Published
What is this permission?
When should I use an exact alarm?
What is the type of this permission?
What happens when the user revokes this permission?
My app uses AlarmManager, should I change anything?
My app uses WorkManager, should I change anything?
What do I need to update in my app?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.escodro.alkaa">
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<application/>
</manifest>
val alarmManager: AlarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
val hasPermission: Boolean = alarmManager.canScheduleExactAlarms()
view raw MainActivity.kt hosted with ❤ by GitHub
val intent = Intent().apply {
action = Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM
}
startActivity(intent)
view raw MainActivity.kt hosted with ❤ by GitHub
internal class MyBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
AlarmManager.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED -> {
// reschedule all the exact alarms
}
}
}

The ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED will be sent to both runtime and manifest receivers. In our example, registering it via manifest will look like:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.escodro.alarm">
<application>
<receiver
android:name=".TaskReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
</intent-filter>
</receiver>
</application>
</manifest>

Job Offers

Job Offers

There are currently no vacancies.

OUR VIDEO RECOMMENDATION

,

One does not simply: migrating to Android 12

A not so easy migration to support Android 12! This talk will show you all the subtleties you need to know before migrating your applications to Android 12. From the Manifest to PendingIntent, through the…
Watch Video

One does not simply: migrating to Android 12

Julien Salvi
Lead Android Engineer
Aircall

One does not simply: migrating to Android 12

Julien Salvi
Lead Android Enginee ...
Aircall

One does not simply: migrating to Android 12

Julien Salvi
Lead Android Engineer
Aircall

Jobs

What’s next?
External resources

 

Thanks to Bruno Kenji Tiba.

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
In this article, we will go through the improvements that Android12 brings for Exact…
READ MORE
blog
Splash screen is the initial screen you’ll see when you open your app. It…
READ MORE
blog
During I/O 2021, Google announced the latest stage for Material Design, Material You (or…
READ MORE
blog
Google announced Android 12 (L) on October 2021 and by March 2022 the stable…
READ MORE
Menu