android 监听系统新安装程序的广播

来源:互联网 发布:手机淘宝首页红包 编辑:程序博客网 时间:2021/02/28 10:58
private class MyReceiver extends BroadcastReceiver{@Overridepublic void onReceive(Context context, Intent intent) {// TODO Auto-generated method stubif(intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)){//Toast.makeText(context, intent.getDataString().substring(8), 2000).show();String packName = intent.getDataString().substring(8);//packName为所安装的程序的包名packagNameList.add(packName);}}}
 
       //监听系统新安装程序的广播        receiver = new MyReceiver();        IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);        filter.addDataScheme("package");    //必须添加这项,否则拦截不到广播        registerReceiver(receiver, filter);

	
				
		
原创粉丝点击