AndroidManifest 中的示例 AlarmController 应用程序服务注册

发布于 2024-10-08 18:07:17 字数 934 浏览 0 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

末骤雨初歇 2024-10-15 18:07:17

您的 元素中需要一个 元素,指示实现该服务的类。

这是我的一本书中的示例项目,演示了其用法服务的。

这是一个示例项目演示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 of AlarmManager when you want the alarms to wake up the phone.

三生一梦 2024-10-15 18:07:17

我刚刚发现它,正如“CommonsWare”在另一个答案中所说,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>
        <service android:name="AlarmService_service" />    

    </application>


</manifest> 

因此无论您使用什么服务、接收器、活动等,您都需要在 AndroidManifest.xml 中注册它。

I just found it as the "CommonsWare" said in the other answer there needs to be a service tag in 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>
        <service android:name="AlarmService_service" />    

    </application>


</manifest> 

So whatever service, reciever, activity and etc you are using, you need to register it in your AndroidManifest.xml.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文