开发者

Can I add multiple receivers to my Manifest?

开发者 https://www.devze.com 2023-03-23 10:12 出处:网络
Ok so I am making a set of widgets that w开发者_Python百科ill simply open up a specific app when pressed. I am fairly new at developing, so my question is if I can just keep adding a new receiver to t

Ok so I am making a set of widgets that w开发者_Python百科ill simply open up a specific app when pressed. I am fairly new at developing, so my question is if I can just keep adding a new receiver to the Manifest for each individual widget? I tried it and it was working but it then got to a point where all the new receivers I added would give me an FC when I went to apply them, the DDMS would say "unable to instantiate receiver." I provided a copy of my manifest below (with 3 receivers), also if there is a better way to go about this then please let me know. Thanks.

<?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>


Try using the full path to your receiver. There is no limit to how many receivers you can have.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消