Вопрос

How can I open device clock from my activity .

I am making a simple app in which user can set alarms For which I want to open device clock using onclicklistner I tried to search on google but didn't find anything.

Это было полезно?

Решение 2

Every manufacturer has a different clock implementation. You need to hardcode it like the answer here:

https://stackoverflow.com/a/4281243/1199931

Другие советы

You can open alarm clock by setting the timer or without timer.Use the following code you will be able to achieve the alarm clock. where timersec = time in seconds

In java:

Intent i = new Intent(AlarmClock.ACTION_SET_TIMER);
i.putExtra(AlarmClock.EXTRA_LENGTH, timerSec);
startActivity(i);

In kotlin:

val i = Intent(AlarmClock.ACTION_SET_TIMER)
 i.putExtra(AlarmClock.EXTRA_LENGTH, timerSec)
 startActivity(i)

add permission in manifest file

<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top