应用安装和卸载
- 定义广播接收者 用来接收事件(应用安装和卸载的事件)
public class MyReceiver extends BroadcastReceiver { private static final String TAG = "MyReceiver"; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals("android.intent.action.PACKAGE_ADDED")){// System.out.println("应用安装了"); Log.e(TAG, "onReceive: 应用安装了" ); } if (action.equals("android.intent.action.PACKAGE_REMOVED")){// System.out.println("应用卸载了"); Log.e(TAG, "onReceive: 应用卸载了" ); } }}
- 清单文件配置