There are many ways to install and uninstall the software on Android phones. you can install the software on your mobile phone.ProgramYou can also use third-party software management to install and uninstall Android applications. In this article, ataaw. com describes how to install and uninstall other applications in our own programs during development.
A. Software InstallationCodeImplementation. The action is intent. action_view.
// Installer APK file path string filename = environment. getexternalstoragedirectory () + apkname; // create URI uri = Uri. fromfile (new file (filename); // create intent = new intent (intent. action_view); // sets the URI and type intent. setdataandtype (Uri, application/vnd. android. package-Archive "); // execute the intent to install startactivity (intent );
B. Software Uninstall code implementation. Note that action is intent. action_delete.
// Create URI packageuri = URI through the package name of the program. parse ("package: package name"); // create intent = new intent (intent. action_delete, packageuri); // execute the uninstall program startactivity (intent );
We can see that the above program installation and uninstallation code are implemented by calling the system's own program through intent to install and uninstall the program. In addition, we can also directly call the android installation and uninstall program interfaces, but ataaw. com thinks that calling the built-in installation and uninstallation functions of the system is sufficient and convenient to use.
Address: http://www.ataaw.com/develop/334.html