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


    Android Engineer

    American Express
    Phoenix, USA
    • Full Time
    apply now

    API Engineer

    American Express
    London
    • Full Time
    apply now

    Mobile Developer Android (m/w/d) Firebase

    REWE digital
    Köln / Cologne
    • Full Time
    apply now
Load more listings

OUR VIDEO RECOMMENDATION

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
Some apps respond to notification taps by launching an app component (Service, BroadcastReceiver) that…
READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu