Hi I am working with android . I had created a webview with splash screen with a progress bar. My app initially load the splash screen and the url load as background.when url load completely,the splash screen will disappear and page will be show.this part is working proper.But when I am using progress bar along with splash screen,the progress bar not working..How can I implement progress bar with splash screen...please help me ,I am new to android development and thanks :)
here is my code
public class WebViewExample extends Activity {
private WebView mWebView;
ProgressBar progressBar;
Context context;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); // remove titlebar
setContentView(R.layout.main);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if(isNetworkStatusAvialable (getApplicationContext())) {
mWebView = (WebView) findViewById(R.id.webview);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new wapWebViewClient());
mWebView.loadUrl("http://facebook.com");
} else {
Toast.makeText(getApplicationContext(), "internet is not avialable ", Toast.LENGTH_LONG).show();
}
}
public static boolean isNetworkStatusAvialable (Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null)
{
NetworkInfo netInfos = connectivityManager.getActiveNetworkInfo();
if(netInfos != null)
if(netInfos.isConnected())
return true;
}
return false;
}
private class wapWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// when the page loaded splash screen has been invisible
mWebView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// if any error occured this message will be showed
Toast.makeText(WebViewExample.this, "Error is occured, please try again..." + description, Toast.LENGTH_LONG).show();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
// setting of back button
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}