应用的卸载安装(无序广播)

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>

 

posted on 2017-02-19 16:06  LoaderMan  阅读(289)  评论(0编辑  收藏  举报

导航