Android代码如何监控apk安装_卸载_…
2013-06-27 16:29
495 查看
public class GetBroadcast extends BroadcastReceiver {
private static GetBroadcast mReceiver = new
GetBroadcast();
private static IntentFilter mIntentFilter;
public static void registerReceiver(Context context) {
mIntentFilter = new IntentFilter();
mIntentFilter.addDataScheme("package");
mIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
mIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
mIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
context.registerReceiver(mReceiver, mIntentFilter);
}
public static void unregisterReceiver(Context context) {
context.unregisterReceiver(mReceiver);
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
Toast.makeText(context, "有应用被添加",
Toast.LENGTH_LONG).show();
} else if (Intent.ACTION_PACKAGE_REMOVED.equals(action))
{
Toast.makeText(context, "有应用被删除",
Toast.LENGTH_LONG).show();
}
else if (Intent.ACTION_PACKAGE_REPLACED.equals(action))
{
Toast.makeText(context, "有应用被替换",
Toast.LENGTH_LONG).show();
}
}
}
private static GetBroadcast mReceiver = new
GetBroadcast();
private static IntentFilter mIntentFilter;
public static void registerReceiver(Context context) {
mIntentFilter = new IntentFilter();
mIntentFilter.addDataScheme("package");
mIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
mIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
mIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
context.registerReceiver(mReceiver, mIntentFilter);
}
public static void unregisterReceiver(Context context) {
context.unregisterReceiver(mReceiver);
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
Toast.makeText(context, "有应用被添加",
Toast.LENGTH_LONG).show();
} else if (Intent.ACTION_PACKAGE_REMOVED.equals(action))
{
Toast.makeText(context, "有应用被删除",
Toast.LENGTH_LONG).show();
}
else if (Intent.ACTION_PACKAGE_REPLACED.equals(action))
{
Toast.makeText(context, "有应用被替换",
Toast.LENGTH_LONG).show();
}
}
}
相关文章推荐
- Android 代码监控apk安装,卸载,替换
- Android 代码监控apk安装,卸载,替换
- Android 代码监控apk安装,卸载,替换
- Android 代码监控apk安装,卸载,替换
- ANDROID代码实现APK文件的安装与卸载
- android apk应用程序如何用代码实现 自己安装自己(自升级)?
- ANDROID代码实现APK文件的安装与卸载
- Android实现用代码简单安装和卸载APK的方法
- Android代码实现APK文件的安装与卸载
- Android APK安装与卸载的代码实现
- ANDROID代码实现APK文件的安装与卸载
- ANDROID代码实现APK文件的安装与卸载
- Android代码实现APK文件的安装与卸载
- Android 监听apk安装替换卸载广播的实现代码
- Android 监听apk安装替换卸载广播的实现代码
- Android教程之如何安装(卸载)apk文件到模拟器
- ANDROID代码实现APK文件的安装与卸载
- Android教程之如何安装(卸载)apk文件到模拟器
- Android代码实现APK文件的安装与卸载
- android代码安装和卸载apk