Enable and disable Android alarms via code

Asked

Viewed 173 times

1

I am creating an application and in a certain part I will need the application to activate and deactivate alarms (from the phone itself). I searched the Internet, but I couldn’t find anything to help me with the description. I don’t know which classes or library can be used and if it’s really possible.

  • What alarms are you referring to?

  • As already said "[...] activate and deactivate alarms (from the mobile phone itself)"

  • What are "alarms (from the mobile phone itself)"?

  • The alarms that comes in an app "factory", which already comes along with the phone. I mean the alarm, when I say alarm.

1 answer

2


There’s no way to do that. There’s no way you can even get a list of all the active alarms in the system, for example. Unless the app that triggered the alarm provides services for this, using Contentprovider for example.

What you can do is use the Do not disturb. When your app starts, you launch an dnd and when to close.

This link can help you with implementation https://stackoverflow.com/questions/31862753/android-how-to-turn-on-do-not-disturb-dnd-programmatically

Remembering that you will have to, depending on the version of android(6.0+), ask the user for permission to use this service.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.