Issue
There are lots of questions regarding the WebView in Android taking too long to load, however I'd like to be able to time exactly how long it takes to completely load, and then display the result.
Is this possible? I could start a timer but does the WebView have an HTML OnLoad style call once it has loaded?
The code I have is basic:
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.pageloadtest);
webView = (WebView) findViewById(R.id.webView1);
webView.loadUrl("http://www.airometricwireless.com");
}
This loads the page fine. I just need to time how long it takes.
Solution
Probably not scientifically accurately, but I guess you could call
long a, b;
mWebView.setWebViewClient(new WebViewClient() {
public void onPageStarted(WebView view, String url) {
a = (new Date()).getTime;
}
public void onPageFinished(WebView view, String url) {
b = (new Date()).getTime;
}
});
Then b - a.
Hope it helps.
Best regards.
Answered By - FeleMed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.