android - 我可以在我的 list 中添加多个接收者吗?

标签 android android-manifest manifest receiver

好的,所以我正在制作一组小部件,这些小部件将在按下时简单地打开一个特定的应用程序。我在开发方面相当陌生,所以我的问题是我是否可以继续为每个单独的小部件向 Manifest 添加一个新的接收器?我尝试了它并且它正在工作,但它后来到了一个点,当我去应用它们时,我添加的所有新接收器都会给我一个 FC,DDMS 会说“无法实例化接收器”。我在下面提供了我的 list 的副本(有 3 个接收者),如果有更好的方法来解决这个问题,请告诉我。谢谢。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.natehoch96.widgets.Template"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Main"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

            <receiver android:name=".Test1"     android:label="@string/widget_test1">
                <intent-filter>
                    <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                </intent-filter>
                <meta-data android:name="android.appwidget.provider" android:resource="@xml/test1_provider" />
            </receiver>

            <receiver android:name=".Test2" android:label="@string/widget_test2">
                <intent-filter>
                    <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                </intent-filter>
                <meta-data android:name="android.appwidget.provider" android:resource="@xml/test2_provider" />
            </receiver>

            <receiver android:name=".Test3" android:label="@string/widget_test3">
                <intent-filter>
                    <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                </intent-filter>
                <meta-data android:name="android.appwidget.provider" android:resource="@xml/test3_provider" />
            </receiver>

最佳答案

尝试使用接收器的完整路径。您可以拥有多少个接收器没有限制。

android:name=".Test3" --> android:name="com.yourpackage.Test3"

关于android - 我可以在我的 list 中添加多个接收者吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6863383/

相关文章:

android - 如何在一个地方定义按钮背景并在整个应用程序中使用?

android - 使用 SimpleCursorAdapter 从 Cursor 更改值

java - 程序类型已存在 : com. google.common.annotations.GwtCompatible

android - 如何添加应用程序小部件提供程序类

office365 - 仅在 Web 版办公产品上启用 Office 加载项

android - 关于安卓 :configChanges

safari - 应用程序缓存事件 noupdate 在 Safari 浏览器上不会间歇性触发。

Android 数据库错误 - getWriteableDatabase

安卓:单元测试

android - 始终在 AndroidManifest 文件中声明 Activity 和服务?