Android Development (30) Use WebView and click the link on the webpage to create a temporary QQ session WPA

Source: Internet
Author: User

On the PC end, We can click a URL link to start QQ. This is a good user jump experience. Very convenient.

The links used are as follows:

<A target = "_ blank" href = "http://wpa.qq.com/msgrd? V = 3 & uin = & site = qq & menu = yes"
> Click </a>

Replace 8888888 with your QQ number.

 

Can this be used in android? In fact, it can be done in the default browser (or UC. The experience is not that good when using custom webView.

We often reload the following setWebViewClient objects in WebView.

webView1.setWebViewClient(new WebViewClient() {public boolean shouldOverrideUrlLoading(WebView view, String url) {view.loadUrl(url);return true;}});

If you do so, you cannot jump to QQ. Why?

After capturing the sent request packet, I found that in the request of the http://wpa.qq.com, the actual request was also sent starting with mqqwpa: // im/chat.

Mqqwpa: // This Part of the URL is called the sechme part of the URL. It is similar to http: //, https: //, http: //, and https: // It is a webpage that can be opened. It is handled by webView, while others are handled by default. In this way, we can call QQ after clicking on the URL link.

Therefore, you need to overload the shouldInterceptRequest method to intercept other sechme processes.

 

As shown below:

webView1.setWebViewClient(   (url.startsWith("http") || url.startsWith("https" =  

 

 

 

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.