Android监听应用程序安装和卸载
来源:互联网 发布:emui源码下载 编辑:程序博客网 时间:2024/05/17 21:55
第一、 新建监听类:BootReceiver继承BroadcastReceiver
package com.rongfzh.yc;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent){
//接收安装广播
if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
String packageName = intent.getDataString();
System.out.println("安装了:" +packageName + "包名的程序");
}
//接收卸载广播
if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) {
String packageName = intent.getDataString();
System.out.println("卸载了:" + packageName + "包名的程序");
}
}
}
第二、 修改AndroidManifest.xml配置文件,添加广播介绍,添加监听的权限
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rongfzh.yc"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".PakDetectActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".BootReceiver"
android:label="@string/app_name">
<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>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
</manifest>
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- 【Android】监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android监听应用程序安装和卸载
- Android利用系统广播---监听应用程序安装和卸载
- Android利用系统广播---监听应用程序安装和卸载
- Android利用系统广播---监听应用程序安装和卸载
- Android利用系统广播---监听应用程序安装和卸载
- Android利用系统广播---监听应用程序安装和卸载
- C# 将picturebox放入panel中,增加滚动条
- 完成端口(CompletionPort)详解 - 手把手教你玩转网络编程系列之三
- HDU2042 不容易系列之二
- oops
- AppDelegate
- Android监听应用程序安装和卸载
- 网站备案制度能不成改成登记制度呢
- 指针与引用(反汇编)
- 0106 单例模式的7种写发【基础】
- iOS图片拉伸技巧
- 程序启动过程
- Solr学习笔记之在schema.xml中定义字段
- 最最基本的框架宏使用RUNTIME_CLASS DECLARE_DYNAMIC IMPLEMENT_RUNTIMECLASS
- java 遍历map时删除元素