Open the Android app directly from the browser

Source: Internet
Author: User

Demand

Open the Android app directly from your mobile browser. If the specified Android app is already installed locally, open it directly or download the app's installation file (or jump to the download page) if it is not installed.


Achieve results

If the app is already installed on your phone, open it directly and start the download if it is not installed.

Implementation method

1. Set a schema for the startup activity of the Android app as follows:

<data android:host= "Splash" android:scheme= "Huiyy"/>


2. When the user clicks the link in the browser, create an invisible iframe dynamically, and let the IFRAME load the schema in step 1 as follows:

/*scheme: Must *///scheme_ios: ' huiyy://',//scheme_adr: ' Huiyy://splash ', var IFR = document.createelement (' iframe '); IFR.SRC = Ua.indexof (' os ') > 0? CONFIG.SCHEME_IOS:CONFIG.SCHEME_ADR;


3, if no jump succeeds within the specified time, then the current page jumps to the apk (or download page) as follows:

window.location = Download_url;

HTML code

<!doctype html>

Androidmanifest.xml

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/         Android "package=" Com.example.downappdemo "android:versioncode=" 1 "android:versionname=" 1.0 "> <uses-sdk android:minsdkversion= "8" android:targetsdkversion= "/> <application android:allowbackup" = "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/A Pptheme "> <activity android:name=" com.example.downappdemo.MainActivity "android:label= "@string/app_name" > <intent-filter> <action android:name= "Android.intent.action.MAI N "/> <category android:name=" Android.intent.category.LAUNCHER "/> &LT;/INTENT-FILTER&G            T <intent-filter> <action android:name= "Android.intent.action.VIEW"/> <categor Y android:name= "android.iNtent.category.DEFAULT "/> <category android:name=" Android.intent.category.BROWSABLE "/> <data android:host= "Splash" android:scheme= "Huiyy"/> </intent-filter> &LT;/ACTIVITY&G    T </application></manifest>





Open the Android app directly from the browser

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.