删除Android包

Android删除包有很多种方法,其中一种通过Intent删除,代码如下:

	
	public boolean unload (String n){
		
		boolean res = true;
		
		try{
			// 通过包名创建URI
			Uri pu = Uri.parse("package:" + n);
			// 创建Intent
			Intent i = new Intent(Intent.ACTION_DELETE, pu);
			// 执行卸载程序
			startActivity(i);	
			res = true;
		}
		catch(Exception e){
			res = false;
		}
		finally{
			return res;
		}		
		
	}

n是应用的包名,通过包名获得URI,Intent.ACTION_DELETE表示删除该包。

posted @ 2013-11-22 17:57  MSTK  阅读(355)  评论(0编辑  收藏  举报