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" > <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> <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!
source share