清单中的接收器标签两次

时间:2014-03-28 22:08:59

标签: android broadcastreceiver android-manifest android-appwidget

我正在尝试根据本网站http://www.developer.com/ws/android/programming/Creating-a-Home-Screen-App-Widget-on-Android-3833306.htm

上的教程创建应用小部件

但我很困惑为什么清单中有两个几乎相同的接收器标签。有人可以解释原因吗?

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mamlambo.imageswidget"
    android:versionCode="1"
    android:versionName="1.0">
    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:debuggable="true">
        <activity
            android:name=".ImagesWidgetConfiguration"
            android:label="@string/app_name">
            <intent-filter>
                <action
                    android:name="android.intent.action.MAIN" />
                <category
                    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action
                    android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
            </intent-filter>
        </activity>
        <receiver
            android:name="ImagesWidgetProvider">
            <intent-filter>
                <action
                    android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/imageswidget_info" />
        </receiver>
        <receiver
            android:name="ImagesWidgetProvider">
            <intent-filter>
                <action
                    android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                    <data android:scheme="images_widget" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/imageswidget_info" />
        </receiver>
    </application>
    <uses-sdk
        android:minSdkVersion="3" />
</manifest>

1 个答案:

答案 0 :(得分:0)

可能是您的正确代码:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mamlambo.imageswidget"
    android:versionCode="1"
    android:versionName="1.0">
    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:debuggable="true">
        <activity
            android:name=".ImagesWidgetConfiguration"
            android:label="@string/app_name">
            <intent-filter>
                <action
                    android:name="android.intent.action.MAIN" />
                <category
                    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action
                    android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
            </intent-filter>
        </activity>

        <receiver
            android:name="ImagesWidgetProvider">
            <intent-filter>
                <action
                    android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                    <data android:scheme="images_widget" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/imageswidget_info" />
        </receiver>
    </application>
    <uses-sdk
        android:minSdkVersion="3" />
</manifest>

它会奏效。希望