This article describes the method of Android implementation to simply install and uninstall APK with code. Share it for your reference, as follows:
public class TestInstallAPK extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub (savedInstanceState); // (); installFile(); } /** * install APK code */ private void installFile(){ Intent intent = new Intent(Intent.ACTION_VIEW); (Intent.FLAG_ACTIVITY_NEW_TASK); (.ACTION_VIEW); // String type = getMIMEType(f); // ((f), type); (("file://" + "/sdcard/Android_gc.apk"), "application/-archive"); (intent); } /** * uninstall APK code */ private void unInstallFile(){ Uri uri=("package:"); Intent intent = new Intent(Intent.ACTION_DELETE,uri); (intent); } }
For more information about Android related content, please check out the topic of this site:Android development introduction and advanced tutorial》、《Android debugging skills and solutions to common problems》、《Android multimedia operation skills summary (audio, video, recording, etc.)》、《Summary of the usage of basic Android components》、《Android View View Tips Summary》、《Android layout layout tips summary"and"Android control usage summary》
I hope this article will be helpful to everyone's Android programming design.