How can we use html web pages and local apps to transmit data? After research, I found that there are still some methods. I have summarized them and there are several methods.
1. Open the Android local app on the html page
1. Compile a simple html page
Insert title here Open app
2. Local Android app Configuration
Add the following elements to intent-filte in the inventory file of AndroidManifest:
Example:
Then, use the "mobile browser" or "webview" method to open the local html webpage and click "open APP" to enable the specified local app.
2. How to use this method to obtain data from a webpage
It doesn't make much sense to open it. The most important thing is that we want to transmit data. How can we transmit data?
We can use the above method to pass some data to the local app. First, let's change the webpage. After the code is modified:
Insert title here Open app
(1). If you open this webpage through a browser, you can obtain data in the following ways:
Uri uri = getIntent().getData(); String test1= uri.getQueryParameter("arg0"); String test2= uri.getQueryParameter("arg1");
(2) If you use webview to access this webpage, the operations for getting data are as follows:
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; }});