Install and uninstall software in Android code

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.