`
想不尽的念
  • 浏览: 24174 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Android PackageManager 卸载包的方法

 
阅读更多
		PackageManager pkgManager = mContext.getPackageManager();
		// 需要system权限
		PackageDeleteObserver observer = new PackageDeleteObserver(currVirus, 1);
		pkgManager.deletePackage(pakName, observer, 0);


	private class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
		private int position;
		private int mFlag;

		public PackageDeleteObserver(int index, int flag) {
			position = index;
			mFlag = flag;// 0卸载1个包,1卸载N个包 N>1
		}

		@Override
		public void packageDeleted(String arg0, int arg1)
				throws RemoteException {
			// TODO Auto-generated method stub
         //arg0是pakname,arg1是具体没了解,卸载成功后这里是1
			LLog.e("###packageDeleted +++" + arg0 + "---" + arg1);
			Message msg;
			msg = mHandle.obtainMessage();
			msg.what = FLAG_DELETE_VIRUS;
			msg.arg1 = position;
			msg.arg2 = mFlag;
			msg.sendToTarget();
		}
	}

    <uses-permission android:name="android.permission.DELETE_PACKAGES" />
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics