1. First, write a simple HTML page
2, the configuration of the Android local app
Add the following elements to the Intent-filte in the androidmanifest manifest file: <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:host= "my.com " Android:scheme= "M"/></intent-filter>
Examples are as follows:
Then use "mobile browser" or "WebView" way to open this local HTML page, click "Open App" to successfully open the local designated app
How to use this method to get the data brought over by the webpage
Only open is not interesting, the most important thing is that we have to pass the data, then how to pass the data?
We can use the above method to pass some data to the local app, then first we change the Web page, after the code modified:
(1). If you open this Web page through a browser, the way to get the data is:
Uri uri = getintent (). GetData (); String test1= uri.getqueryparameter ("arg0"); String test2= uri.getqueryparameter ("arg1");
(2) If you use WebView to access the webpage, the operation to get the data is:
Webview.setwebviewclient (New Webviewclient () { @Override public boolean shouldoverrideurlloading (WebView View, String URL) { Uri uri=uri.parse (URL); if (Uri.getscheme (). Equals ("M") &&uri.gethost (). Equals ("my.com")) { String arg0=uri.getqueryparameter ( "arg0"); String arg1=uri.getqueryparameter ("arg1"); } else{ view.loadurl (URL); } return true; }});
How do I invoke the local Android app from an HTML page?