Android Silent Installation/background Installation

Source: Internet
Author: User

The Silent Installation of Android is actually very simple. Today, it is very complicated to find information on the Internet for half a day, what requires system installation permissions, calling system hidden APIs, compiling in the system environment, and the same process as systemui. I don't know if they have implemented Silent Installation, But I have failed in all their ways.

Next I will talk about my silent installation implementation method. The effect of the test is the same as that of pods, and the implementation is very simple:

1. The machine supporting silent installation must be root. I don't need to talk about it more.

2. Run the PM command to install the SDK.

3. Note that the PM command does not support Chinese characters. If the path contains Chinese characters, installation may fail!

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();                } catch (IOException e) {                    e.printStackTrace();                }            }        }        return result;    }

You do not need to declare any permissions in manifest.

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.