In on create
WebView wv = (WebView)findViewById(R.id.webView1);
wv.getSettings().setJavaScriptEnabled(true);
if(isInternetAvailable()){
wv.setWebViewClient(new myWebClient(){
@Override
public void onPageFinished(WebView view, String url)
{
/* Call whatever, It's finished loading. */
// wv.setVisibility(View.VISIBLE);
// iv.setVisibility(View.GONE);
if (checkk==1)
{
}
else{
wv.setVisibility(View.VISIBLE);
iv.setVisibility(View.GONE);
}
}
});
wv.loadUrl("http://www.google.com");
}else {
Toast.makeText(getApplicationContext(), "Use internet for better performance", Toast.LENGTH_LONG).show();
}
public class myWebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
// or if you want to open default link in webiview and external in other browser
// if (Uri.parse(url).getHost().equals("http://www.google.com")) {
// This is my web site, so do not override; let my WebView load the page
// return false;
}
// Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// startActivity(intent);
// return true;
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// Toast.makeText(frontPagee.this, "Your Internet Connection May not be active Or " + description , Toast.LENGTH_LONG).show();
Toast.makeText(frontPagee.this, "Your Internet Connection May not be active ", Toast.LENGTH_LONG).show();
// checkk=1;
}
}
No comments:
Post a Comment