Open the app via a connection on your phone's browser

Source: Internet
Author: User

Implemented in the Android system

1, in the system system comes with the browser

First make the HTML page, the page content format is as follows:

This sentence will be all right.

The meanings of each item are as follows:

Scheme: Identify the app that starts. ※ The following details are described

Host: Proper description

Path: The key※ required to pass the value is not also available

Query: Get the value of key and Value※ no also can

Write it well as a test, as follows:

<a href= "myapp://jp.app/openwith?name=zhangsan&age=26" > Start Application </a>  

Next comes the Android side.
First, add the following to the main activity of Androidmanifest.xml. (given when activating activity)

* Items must be added

<intent-filter>      <action android:name= "Android.intent.action.VIEW"/>      <category android: Name= "Android.intent.category.DEFAULT"/>      <category android:name= "Android.intent.category.BROWSABLE"/ >      <data android:scheme= "MyApp" android:host= "Jp.app" android:pathprefix= "/openwith"/>  </ Intent-filter>

The contents of the HTML description are added to <data .../>.
The required content is only scheme, and no other content app can be launched.

※ Note: The contents of Intent-filter "Android.intent.action.MAIN" and "Android.intent.category.LAUNCHER" are 2, and cannot be mixed with this additional content.
So, if you join the same activity, do this as follows, or it will cause the app icon to disappear on the desktop.

<intent-filter>      <action android:name= "Android.intent.action.MAIN"/>      <category android: Name= "Android.intent.category.LAUNCHER"/>  </intent-filter>  <intent-filter>      < Action android:name= "Android.intent.action.VIEW"/>      <category android:name= " Android.intent.category.DEFAULT "/>      <category android:name=" Android.intent.category.BROWSABLE "/>      <data android:scheme= "MyApp" android:host= "Jp.app" android:pathprefix= "/openwith"/>  

In that case, no problem.

Next, add the following code where the activity needs to be valued, and I'll write it directly in the OnCreate function:

Intent I_getvalue = Getintent ();
String action = I_getvalue.getaction ();

if (Intent.ACTION_VIEW.equals (ACTION)) {
Uri uri = I_getvalue.getdata ();
if (uri! = null) {
String name = Uri.getqueryparameter ("name");
String age= uri.getqueryparameter ("Age");
}
}

This will get the value passed to the URL.

2. In a third-party browser

Host an HTTP service in a local application, the local service address is 127.0.0.1:8765, and the host is used to monitor the service data and open itself.

3. Open in

After registering your app on an open platform, you can get AppID and jump to your app with this AppID.
The iOS platform format is as follows: Appid://openwebview/?ret=0,appid to replace the actual, back can take parameters, in your app can receive.
Example: Location.href = wx234ad233ae222://openwebview/?ret=0

Implemented in iOS (no Apple device, only Mac emulation)

1, in the system comes with the browser
  //to avoid the ' protocol not supported ' alert, fail must open another app.             varAppStore = "Itms://itunes.apple.com/us/app/facebook/id284882215?mt=8&uo=6"; functionAppLink (fail) {return function(){                      varClickedat = +NewDate; //During tests on 3G/3GS This timeout fires immediately if less than 500ms. SetTimeout (function(){                                //to avoid failing in return to Mobilesafari, ensure freshness!                               if(+NewDate-clickedat < 2000) {window.location=fail; }                                }, 500);              }; } document.getElementById ("Applink1"). onclick =AppLink (AppStore); document.getElementById ("Applink2"). onclick = AppLink (AppStore);

The principle is to add a settimeout method to the hyperlink Click event in the HTML page.

If in the iphone above 500ms, the native application can resolve the protocol and open the program, the callback method fails, if the native no application can resolve the protocol, or 500MS does not open a program, then execute settimeout inside the function, is to jump to Apple's itunes.

2. In a third-party browser

NetEase Cloud Music address, can open cloud music directly

https://itunes.apple.com/app/id590338362

3. Open in

After registering your app on an open platform, you can get AppID and jump to your app with this AppID.
The iOS platform format is as follows: Appid://openwebview/?ret=0,appid to replace the actual, back can take parameters, in your app can receive.
Example: Location.href = wx234ad233ae222://openwebview/?ret=0

Open the app via a connection on your phone's browser

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.