How to get an intention. Assignment ACTION_PACKAGE_ADDED. ACTION_PACKAGE_REMOVED in appwidget?

How to get Intent.ACTION_PACKAGE_ADDED and Intent.ACTION_PACKAGE_REMOVED in appwidget?

I tried to add an intent filter in the manifest:

  <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <!-- The widget provider --> <receiver android:name=".NetsWidgetProvider"> <intent-filter> <action android:name="android.intent.action.PACKAGE_REMOVED"/> <action android:name="android.intent.action.PACKAGE_ADDED"/> <action android:name="com.oozic.widget.incstage.nets.ACTION_NOT_INSTALL"/> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <!-- This specifies the widget provider info --> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widgetinfo" /> </receiver> </application> 

and I also tried registering in Code:

 @Override public void onEnabled(Context context) { registerReceiver(context); Utils.log(TAG, "Register PACKAGE_ADDED PACKAGE_REMOVED"); } private void registerReceiver(Context context) { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); context.getApplicationContext().registerReceiver(this, filter); } 

But both did not work. Thanks!

+4
source share
3 answers

I am broadcasting to my widgets in my custom launcher when it receives the PACKAGE_REMOVED / ADDED message. This is the only work I have found to fix this.

+1
source

The AndroidManifest.xml <data android:scheme="package" /> application solved the problem.

 <receiver android:name=".PackageAddedReceiver"> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED"/> <data android:scheme="package" /> </intent-filter> </receiver> 
+8
source
  <receiver android:name=".NetsWidgetProvider" android:label="@string/appwidget_name" android:icon="@drawable/icon"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="com.oozic.widget.incstage.nets.ACTION_NOT_INSTALL"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/> <action android:name="android.intent.action.PACKAGE_REMOVED"/> <data android:scheme="package" /> </intent-filter> <!-- This specifies the widget provider info --> <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidgetinfo" /> </receiver> 
+3
source

All Articles