Android WebView (External browser) to tune up the app

Source: Internet
Author: User

Recently written projects involve external browsers as well as Project WebView in the app, so summarize below and share with you.

The general method of implementation is still relatively simple,

1: register in the list

  First, in the Androidmanifest file, register a filter

<intent-filter >
<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= "xxx" android:host="xxx"/>
</intent-filter>

Where scheme and host are as follows:

Scheme://host:port/path

Example: nearbar://com.nearbar.android:200/folder/subfolder/etc
\---------/  \---------------------------/ \---/ \--------------------------/
Scheme Host Port Path
\--------------------------------/
Authority

2: Receive in Mainactivity

  

if (Intent.ACTION_VIEW.equals (ACTION)) {
Uri uri = I_getvalue.getdata ();
String data = uri.tostring ();

}

Because the URL in my project is a JSON string, it is parsed to determine the specific operation.

Android WebView (External browser) to tune up the app

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.