Android webview cannot connect to the Internet using cmwap Solution

Source: Internet
Author: User

Android experience in cmwap and other proxy access points

Text/rslhg


1. Some Rom will still get the proxy value set by cmwap In the WiFi environment, so when getting the proxy, judge the mobile network environment. If it is GPRS, no proxy will be obtained.

Connectivitymanager = (connectivitymanager) Context

. Getsystemservice (context. connectivity_service );

Networkinfo activenetworkinfo = connectivitymanager

. Getactivenetworkinfo ();

If (activenetworkinfo! = NULL ){

Int type = activenetworkinfo. GetType ();


// Todo prevents the mobile agent from reading data under WiFi

If (type = connectivitymanager. type_mobile ){

// Fetch proxy

} Else {

// Do not retrieve the proxy

}

}


2. when some rom WebKit are in cmwap, WebKit cannot be connected or is disconnected, you need to add webview in onresume. enableplatformconfigurications ();, onstop add webview. disableplatformconfigurications ();. However, if you need to load the page as soon as you enter this activity, the first page of load will not be loaded and will stay for a long time without error pages and do not call webviewclient. onreceivederror. I have tried sethttpauthusernamepassword.

Personal solution:


Mwebpage. Post (New runnable (){

@ Override

Public void run (){

Mwebpage. loadurl (URL );



}



});


At this time, the first load page will soon call webviewclient. onreceivederror. You can set a flag in webviewclient. onreceivederror and reload the first page.

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.