Http://itindex.net/blog/2014/11/07/1415353560000.html
Click the URL link in your browser to launch a specific app.
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.
Android allows you to open a local app (app) and get the data from your browser by clicking the link in the browser