Android的AlarmClock的强制力接近 [英] Android AlarmClock causing force close

查看:675
本文介绍了Android的AlarmClock的强制力接近的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个应用程序,设置一个报警,和这里的相关code这是造成一个强制关闭:

I'm writing an app that sets an alarm, and here's the relevant code that's causing a force close:

Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_HOUR, hours);
i.putExtra(AlarmClock.EXTRA_MINUTES, minutes);
i.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
startActivity(i);

startActivity(我)引起的力接近。我试图捕捉 ActivityNotFoundException 键,显示敬酒,但部队密切仍在进行之中。

The startActivity(i) is causing the force close. I tried catching ActivityNotFoundException and displaying a Toast, but the force close is still happening.

我真的很新的到Android编程,和我开始觉得有其他的力量在这里工作......确实清单文件需要被编辑考虑到活动不是天然的这个应用程序(如闹钟),这个应用程序会尝试启动?

I'm really new to Android programming, and I'm starting to think there are other forces at work here... does the manifest file need to be edited to account for Activities not native to this application (such as the Alarm Clock) that this application tries to start?

编辑:我应该提到,我使用的是Android 2.3.5(API 10级)

I should have mentioned, I'm using Android 2.3.5 (API level 10).

推荐答案

如果您的API是9 +

If your API is 9+,

然后用此权限在你的清单文件,

Then use this permission in your manifest file,

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

编辑:

看看这个网页。机器人 - AlarmClock的

这篇关于Android的AlarmClock的强制力接近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆