4

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

martin1337
  • 2,384
  • 6
  • 38
  • 85

1 Answers1

12

In Java, from activity I do it like this:

startActivity(new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM, Uri.parse("package:"+ getPackageName())));
porlicus
  • 739
  • 1
  • 7
  • 14