I have developed a widget that has certain functionality, but some people have asked me to create a similar widget but with a slight different functionality. Both widgets will look the same but behave slightly different. I tried adding a different receiver for the second widget to my manifest file. I also created a separate widget provider xml file and I have a separate class that implements the AppWidgetProvider with the different functionality. Yet, when I add the second widget to home page, it seems to be using the functionality of the first widget, and not the new functionality.
Here is some of the code:
I have to separate classes that extend the AppWidgetProvider (one for each widget). The class names are iContacts and iContactsQuickDial.
The difference between this two classes is the OnReceive method which implements the different logic. The other methods are exactly the same.
Manifest receivers:
<receiver android:name=".iContacts" android:label="@string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.appwidget.action.CONFIGURATION_CHANGED" />
<action android:name="com.mesa.icontacts.ConfigureContacsActivity.ACTION_UPDATE_WIDGET" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_1" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_2" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_3" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_4" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/icontacts_widget_provider" />
</receiver>
<receiver android:name=".iContactsQuickDial"
android:label="@string/app_name_quick_dial">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.appwidget.action.CONFIGURATION_CHANGED" />
<action android:name="com.mesa.icontacts.ConfigureContacsActivity.ACTION_UPDATE_WIDGET" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_1" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_2" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_3" />
<action android:name="com.mesa.icontacts.iContacts.ACTION_WIDGET_SHOW_CONTACT_4" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/icontacts_quick_dial_widget_provider" />
</receiver>
Both widgets use the same configuration activity since this logic doesn't change.
Both providers: icontacts_widget_provider:
<?xml version="1.0" encoding="UTF-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="300dip"
android:minHeight="75dip"
android:initialLayout="@layout/main"
/>
icontacts_quick_dial_widget_provider
<?xml version="1.0" encoding="UTF-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="300dip"
android:minHeight="75dip"
android:initialLayout="@layout/main"
/>
Note that the layout is the same for both since both widgets must look the same
Any ideas would be appreciated?
Thank you