Android监听应用程序安装和卸载
Android监听应用程序安装和卸载
第一、 新建监听类: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监听应用程序安装和卸载的更多相关文章
- android86 监听SD卡状态,勒索软件,监听应用的安装、卸载、更新,无序广播有序广播
* 添加权限 <uses-permission android:name="android.permission.RECEIVE_SMS"/> * 4.0以后广播接收者 ...
- Android实践 -- 监听应用程序的安装、卸载
监听应用程序的安装.卸载 在AndroidManifest.xml中注册一个静态广播,监听安装的广播 android.intent.action.PACKAGE_ADDED 监听程序卸载的广播 and ...
- 【Android】Android 监听apk安装替换卸载广播
[Android]Android 监听apk安装替换卸载广播 首先是要获取应用的安装状态,通过广播的形式 以下是和应用程序相关的Broadcast Action ACTION_PACKAGE_ADDE ...
- Android监听自身卸载,弹出用户反馈调查
1,情景分析 在上上篇博客中我写了一下NDK开发实践项目,使用开源的LAME库转码MP3,作为前面几篇基础博客的加深理解使用的,但是这样的项目用处不大,除了练练NDK功底.这篇博客,我将讲述一下一个各 ...
- Android监听消息通知栏点击事件
Android监听消息通知栏点击事件 使用BroadCastReceiver 1 新建一个NotificationClickReceiver 类,并且在清单文件中注册!! public class N ...
- Android监听系统短信数据库变化-提取短信内容
由于监听系统短信广播受到权限的限制,所以很多手机可能使用这种方式没法监听广播,从而没办法获取到系统短信,所以又重新开辟一条路. Android监听系统短信数据库内容变化使用场景: 1.监听短信数据库的 ...
- Android监听返回键、Home键+再按一次返回键退出应用
Android监听返回键需重写onKeyDown()方法 Home键keyCode==KeyEvent.KEYCODE_HOME @Override public boolean onKeyDown( ...
- Android监听来电和去电
要监听android打电话和接电话,只需下面2步骤1.第一步,写一个Receiver继承自BroadcastReceiver import android.app.Service; import an ...
- Android监听ScrollView滑动到顶端和底部
Android监听ScrollView滑动到顶端和底部 package cn.testscrollview; import android.os.Bundle; import android. ...
随机推荐
- 关于struts2上传图片临时文件
- //sql过滤关键字
//sql过滤关键字 public static bool CheckKeyWord(string sWord) { //过滤关键字 string StrKeyWord = @"select ...
- SPOJ 10628 Count on a tree(Tarjan离线LCA+主席树求树上第K小)
COT - Count on a tree #tree You are given a tree with N nodes.The tree nodes are numbered from 1 to ...
- springmvc Failed to load resource: the server responded with a status of 404 (Not Found)
jsp页面导入css.js提示上述问题. Spring对静态资源的请求做专门处理 <!-- 对静态资源的请求 --><mvc:resources location="/js ...
- ExtJS笔记 Using Events
Using Events The Components and Classes of Ext JS fire a broad range of events at various points in ...
- 直观友好的单个memcache监控工具:phpmemcache.php
上传phpmemcache.php到指定文件 修改文件中的: define('ADMIN_USERNAME','user'); // Admin Usernamedefine('ADMIN_P ...
- Java工具
1. Groovy shell 可以在Java代码里执行脚本,可以将Java方法配置在文件里 依赖 <dependency> <groupId>org.codehaus.gro ...
- java 向上转型 向下转型
//父类 四边形 class Quadrangle{ public static void draw (Quadrangle q){ } } //子类 public class Parallelog ...
- 忘记Linux root用户的密码怎么办?
以前忘记windows密码的时候,要么用工具清除,要么重装系统.假如你忘记了linux系统的root密码,怎么办呢?是像windows一样用工具破解还是重装系统呢?哈哈,都不用.这方法很简单,现在做一 ...
- js web实现移动端触控
// 触摸事件 $(".m_l_i_l a").on("touchstart", function(){ $(this).css("color&quo ...