一、广播
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
switch (intent.getAction()) {
case Intent.ACTION_PACKAGE_ADDED:
packageName = intent.getData().getSchemeSpecificPart();
Log.e(TAG, "--------安装成功" + packageName);
PackageCallBackUtis.getPackageState(0, packageName);
break;
case Intent.ACTION_PACKAGE_REPLACED:
packageName = intent.getData().getSchemeSpecificPart();
Log.e(TAG, "--------更新成功" + packageName);
PackageCallBackUtis.getPackageState(1, packageName);
break;
case Intent.ACTION_PACKAGE_REMOVED:
packageName = intent.getData().getSchemeSpecificPart();
Log.e(TAG, "--------卸载成功" + packageName);
PackageCallBackUtis.getPackageState(2, packageName);
break;
default:
break;
}
}
二、发广播调出系统卸载界面
private void uninstall(String packagename) {
Uri uri = Uri.parse("package:" + packagename);
Intent intent = new Intent(Intent.ACTION_DELETE, uri);
startActivity(intent);
}