应用的卸载安装(无序广播)
public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if ("android.intent.action.PACKAGE_REMOVED".equals(action)) { System.out.println("卸载了应用程序:"+intent.getData().toString()); }else if ("android.intent.action.PACKAGE_ADDED".equals(action)) { System.out.println("安装了应用程序:"+intent.getData().toString()); } }
清单文件: <receiver android:name="com.example.add_remove.AddRemoveReceiver" > <intent-filter > <action android:name="android.intent.action.PACKAGE_ADDED"/> <action android:name="android.intent.action.PACKAGE_REMOVED"/> <data android:scheme="package"/> </intent-filter> </receiver>
最后,关注【码上加油站】微信公众号后,有疑惑有问题想加油的小伙伴可以码上加入社群,让我们一起码上加油吧!!!