Android 12: Redirect to Alarms & Reminders settings not working
Asked Answered
R

1

5

I want to show snackbar to user, if he has Alarms & Reminders turned off in my App (since Android 12 its mandatory to have this settings enabled in order to register Alarms for example to fire Notifications). But on some phones, it is showing completely different screen without any settings available.

Code:

val snackbar = Snackbar.make(tabBar, getString(R.string.snackbar_alarm_schedule_settings), 7000)
            snackbar.setAction(R.string.snackbar_settings) {
                Intent().apply {
                    action = ACTION_REQUEST_SCHEDULE_EXACT_ALARM
                }.also { startActivity(it) }
            }
            snackbar.view.findText(com.google.android.material.R.id.snackbar_text).run {
                maxLines = 5
            }
            snackbar.show()

Here is comparison of my settings versus how it should look like:

enter image description here

Expectation: enter image description here

Roseliaroselin answered 10/12, 2021 at 13:3 Comment(0)
A
18

In Java, from activity I do it like this:

startActivity(new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM, Uri.parse("package:"+ getPackageName())));
Auburta answered 7/5, 2022 at 16:52 Comment(1)
This worked and should be the accepted answer. I wonder if you can expand on how you knew this was how to do it, given that it's not in the documentation (at least that I could find)?Carey

© 2022 - 2024 — McMap. All rights reserved.