I have 1 Android application project and 1 widget project, they all work fine. Now, I want to include the widget project in the Android application project so that the user installs the application, the widget will also be installed. I liked the below, but it did not work. Any help? Thank you!
In the manifest file:
<application> ............ (this is of android app project. below is of widget)....... <receiver android:name=".widget.PlayerWidgetActivity" > <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/playerwidgetprovider" /> </receiver> <service android:name=".widget.PlayerWidgetActivity$UpdateService" /> <service android:name=".widget.PlayerWidgetActivity$ServiceBindUnbindService" /> </application>
EDIT
: My application is quite large (.APK ~ 10 MB), of course, it has a lot of activity, a lot of services, a lot of broadcast receivers ..... so it takes time to build. I create a new very small application with just activity and put the code for the widget as I put on the big application above. It is working! OH MY GOD! Why he worked on this small application, but not my large application :(
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".activity.ApplicationWithWidgetActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name=".widget.PlayerWidgetActivity" android:icon="@drawable/ic_launcher" android:label="@string/appwidget_name"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/playerwidgetprovider" /> </receiver> <service android:name=".widget.PlayerWidgetActivity$UpdateService" /> <service android:name=".widget.PlayerWidgetActivity$ServiceBindUnbindService" /> </application>
source share