从Android的自定义应用程序设置闹钟自定义、闹钟、应用程序、Android

2023-09-12 05:48:39 作者:别勉强

是新的Andr​​oid开发。我开发了我的第一个应用程序的今天。现在正在开发另外一个了解它的更多。

Am new to android development. I developed my first app today. Now developing another one to understand it more.

我的要求是

1)我将有两个单选按钮,一个是上午10:00,另一种是9:00 AM

1.) I will have two radio buttons, one is 10:00 AM and another one is 9:00 AM

2在点击任一上午10时或上午9时报警器应在我的Andr​​oid默认报警服务设置)。

2.) On clicking either 10:00 AM or 9:00 AM the alarm should set in my android default alarm service.

在谷歌搜索,这些例子仅给出了如何开发自己的报​​警服务(我们正在设置报警和接收相同的在指定的时间和播放铃声)

In google search, the examples are given only how to develop own alarm service (where we are setting alarm and receiving the same at specified time and playing the ring tone)

我不希望出现这种情况。我只是想用我的应用程序作为另一个前端,这将安排在Android的默认时钟应用的报警。

I dont want that. I just wanna use my app as another front end, which will schedule alarm in default clock-app of android.

请提示

推荐答案

这将设置警报上午10点:

This will set an alarm for 10am:

Intent openClockIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
openClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
openClockIntent.putExtra(AlarmClock.EXTRA_HOUR, 10);
context.startActivity(openClockIntent);

您还需要这个权限:

<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>