Android Silent install app create a phone desktop icon and click on the icon to install a new app

Source: Internet
Author: User

When a user installs an app, the app's developers, if they're confident enough or for some other reason, want users to be able to install their own other apps to try, so they can get more users and make the web bigger. So it's easy to understand why many times we have installed a news app, But the mobile desktop has a game market app icon, and then we click on this icon will install the corresponding app game market application. Further, the installation of a silent installation, in the background installed a new application, the user back to the desktop only to find, "OMG when I did this apk I do not know ..."


This time we use a simple method to create a mobile desktop shortcut, and click on the icon to install the new APK app.

Create a shortcut

/**     * Create Shortcut */    private void Setlauncherlogo () {        Intent shortcutintent = new Intent (" Com.android.launcher.action.INSTALL_SHORTCUT ");        The name of the shortcut        Shortcutintent.putextra (intent.extra_shortcut_name, "I am the title");        Set shortcut picture        parcelable icon = Intent.ShortcutIconResource.fromContext (Getapplicationcontext (), r.drawable.img_1 );        Shortcutintent.putextra (Intent.extra_shortcut_icon_resource, ICON);        Set the activity to start after clicking on the shortcut picture, in which activity can customize various behaviors such as installing the new APK app        Shortcutintent.putextra (intent.extra_shortcut_ INTENT, New INTENT (Getapplicationcontext (), Mainactivity.class));        Send broadcast        sendbroadcast (shortcutintent) to the system;    }


Install APK file apk installer here, can be downloaded in the original application in the background and placed in the specified storage space, so that when the click on the shortcut to the target activity is able to install the specified APK file directly.

/**     * Install apk file under a path *    /private void installapk () {        try{            Intent Intent = new Intent (intent.action_ VIEW);            Intent.setdataandtype (Uri.fromfile (New File ("/mnt/sdcard/myapks/xxx.apk")),                    "application/ Vnd.android.package-archive ");            This.startactivity (intent);        } catch (Exception e) {        }finally{        }    }
By calling the installapk () method directly in the target activity OnCreate (), you can click on the desktop icon and install the new app.


, if there is no locally prepared apk, you can choose to go to the server to download the APK and implement the installation.


The above is a simple way to create a desktop shortcut and install a new app. How to install silently in the background, and then find a time to record it later.



Android Silent install app create a phone desktop icon and click on the icon to install a new app

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.