手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android编程实现监控apk安装,卸载,替换的方法
Android编程实现监控apk安装,卸载,替换的方法
摘要:本文实例讲述了Android编程实现监控apk安装,卸载,替换的方法。分享给大家供大家参考,具体如下:publicclassGetBroad...

本文实例讲述了Android编程实现监控apk安装,卸载,替换的方法。分享给大家供大家参考,具体如下:

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_CHANGED.equals(action)){ * Toast.makeText(context, "有应用被改变", Toast.LENGTH_LONG).show(); } */ else if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) { Toast.makeText(context, "有应用被替换", Toast.LENGTH_LONG).show(); } /* * else if(Intent.ACTION_PACKAGE_RESTARTED.equals(action)){ * Toast.makeText(context, "有应用被重启", Toast.LENGTH_LONG).show(); } */ /* * else if(Intent.ACTION_PACKAGE_INSTALL.equals(action)){ * Toast.makeText(context, "有应用被安装", Toast.LENGTH_LONG).show(); } */ } }

希望本文所述对大家Android程序设计有所帮助。

【Android编程实现监控apk安装,卸载,替换的方法】相关文章:

Android实现类似360,QQ管家那样的悬浮窗

android 分辨率适配的方法

Android实现Activities之间进行数据传递的方法

android apk反编译到java源码的实现方法

Android 九宫格的实现方法

Android编程之客户端通过socket与服务器通信的方法

使用android隐藏api实现亮度调节的方法

android将Bitmap对象保存到SD卡中的方法

android通过代码的形式来实现应用程序的安装与卸载

android中查看项目数字证书的两种方法

精品推荐
分类导航