Explanation of the android webviewclient Method

Source: Internet
Author: User

1. Public Boolean shouldoverrideurlloading (webview view, string URL ){

View. loadurl (URL );

Return true;

}

The request is called only when a link is clicked. If this method is rewritten, true is returned, indicating that the link in the webpage is clicked or redirected in the current webview, rather than in the browser.

2. Public void onreceivedsslerror (webview view, sslerrorhandler handler,
Android.net. http. sslerror error ){

Handler. Proceed ();

}

Rewrite this method to allow webview to process HTTPS requests.

3. Public Boolean shouldoverridekeyevent (webview view, keyevent event ){

Return super. shouldoverridekeyevent (view, event );

}

}

Rewrite this method to handle button events in the browser.

4. Public void onloadresource (webview view, string URL ){
// Todo auto-generated method stub
If (Debug ){
Log. D (TAG, "onloadresource ");
}
Super. onloadresource (view, URL );
}

It is called when page resources are loaded, and each resource (slice) is called once.

5. Public void onpagestarted (webview view, string URL, bitmap favicon ){
// Todo auto-generated method stub
If (Debug ){
Log. D (TAG, "onpagestarted ");
}

If (URL. endswith (". APK ")){
Download (URL); // download process
}
Super. onpagestarted (view, URL, favicon );
}

Called when page loading starts.

6. Public void onpagefinished (webview view, string URL ){
// Todo auto-generated method stub
If (Debug ){
Log. D (TAG, "onpagefinished ");
}
Super. onpagefinished (view, URL );
}

Called at the end of page loading.

 

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.