Android - declare widget in manifest

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> 
+4
source share
1 answer

I had the same problem!

Solution - INSTALLING APPLICATION IN A PHONE .

Just move the application to your phone and you will see your widget.

Hope this helps you!

Information from here: http://www.hrupin.com/2012/07/how-to-fix-android-homescreen-widget-installation-widget-as-part-of-android-application

+2
source

Source: https://habr.com/ru/post/1385280/


All Articles