AndroidManifest 中的示例 AlarmController 应用程序服务注册
我是 Android 新手,正在尝试实现示例 AlarmController 应用程序。一切都很好,但警报服务不起作用。我想知道我是否需要在 AndroidManifest.xml 文件中注册这些服务,因为其他活动 a 已注册,如果是的话。我该怎么做,我猜警报控制器代码在 Android 网站上可用,因此我只是放置我的应用程序的 AndroidManifest.xml 代码。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AlarmController"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AlarmActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I am new to Android and trying to implement the sample AlarmController application. Everything is fine but its Alarm Service is not working. I was wondering that do I need to register these services in the AndroidManifest.xml file as the other activities a are registered and if yes. How do I do that, I guess the alarm controller code is Available on Android's website therefore I am just putting the AndroidManifest.xml code of my application.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AlarmController"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AlarmActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
元素中需要一个
元素,指示实现该服务的类。这是我的一本书中的示例项目,演示了其用法
服务
的。这是一个示例项目演示
WakefulIntentService
,我编写的一个开源组件,用于简化AlarmManager
的使用,当您想要闹钟唤醒手机。You need a
<service>
element inside your<application>
element, indicating the class that implements the service.Here is a sample project from one of my books demonstrating the use of a
Service
.Here is a sample project demonstrating
WakefulIntentService
, an open source component I wrote to simplify the use ofAlarmManager
when you want the alarms to wake up the phone.我刚刚发现它,正如“CommonsWare”在另一个答案中所说,AndroidManifest.xml 中需要有一个服务标签,
因此无论您使用什么服务、接收器、活动等,您都需要在 AndroidManifest.xml 中注册它。
I just found it as the "CommonsWare" said in the other answer there needs to be a service tag in AndroidManifest.xml
So whatever service, reciever, activity and etc you are using, you need to register it in your AndroidManifest.xml.