代码实现安装卸载apk

安装

final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory(), APK_FILE_NAME)),
         "application/vnd.android.package-archive");
context.startActivity(intent);


卸载

Uri packageURI = Uri.parse("package:com.myapp");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
context.startActivity(uninstallIntent);



你可能感兴趣的:(apk)