Android silent Installation/background installation & Root permission

Source: Internet
Author: User

Android silent Installation/background installation & Root permission

silent installation is actually very simple, today on the Internet to find information for a long time are said to be very complex, what requires system installation permissions, call system hidden API, need to compile the system environment, need to systemui with the process and so on. I don't know, they did. Silent installation implementation, the pro-test effect is the same as the Pea pod, and the implementation is very simple:

1. A machine that supports silent installation must be root, and this does not require me to speak more.

2. Install with PM instructions.

3. Pay special attention to PM instruction does not support Chinese, it is said that the path of Chinese will cause installation failure!


The key code is as follows:


Execrootcmdsilent ("PM Install-r" + environment.getexternalstoragedirectory (). GetPath () + "/xxx.apk")


public int execrootcmdsilent (String cmd) {        int result =-1;        DataOutputStream dos = null;        try {            Process p = runtime.getruntime (). EXEC ("su");            DOS = new DataOutputStream (P.getoutputstream ());            LOG.I (TAG, cmd);            Dos.writebytes (cmd + "\ n");            Dos.flush ();            Dos.writebytes ("exit\n");            Dos.flush ();            P.waitfor ();            result = P.exitvalue ();        } catch (Exception e) {            e.printstacktrace ();        } finally {            if (dos! = null) {                try {                    dos.close (); c18/>} catch (IOException e) {                    e.printstacktrace ();}}        }        return result;    }


Do not need to declare any permissions in manifest

Android silent Installation/background installation & Root permission

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.