title: How to load url in webview in background while splashscreen is showing?
body: <p>This is my splashscreen activity.</p>
  
  <pre><code>public class Splash extends Activity {
    private static int SPLASH_TIME_OUT=10000;
    protected void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_splash);
      Timer r=new Timer();
      new Handler().postDelayed(r,SPLASH_TIME_OUT);
    }
  
    class Timer implements Runnable{
  
      @Override
      public void run() {
          // TODO Auto-generated method stub
          Intent i=new Intent(Splash.this,MainActivity.class);
          startActivity(i);
          finish();
      }
  
    }
  }
  </code></pre>
  
  <p>This is my MainActivity. This activity Should be performed in background while splashscreen is on the front. Is it advisable to use AsyncTask. How to do that?</p>
  
  <p>If not AsyncActivity, What can I use?</p>
  
  <pre><code>public class MainActivity extends Activity {
    private WebView webview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
  
      webview = (WebView)findViewById(R.id.output);
      webview.getSettings().setJavaScriptEnabled(true);
      webview.getSettings().setLoadsImagesAutomatically(true);
      webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
      webview.getSettings().setAppCacheEnabled(false);
  
      webview.setWebViewClient(new WebViewClient(){
  
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
              view.loadUrl(url);
              if(url.startsWith("tel:")) { 
                  Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); 
                  startActivity(intent); 
                  return true;
              }
              return false;
  
          }
      }
              );
      webview.loadUrl("http://www.example.com");
    }
      //this is to go back to previous pages if exists
      public boolean onKeyDown(int keyCode, KeyEvent event) {
          if(event.getAction() == KeyEvent.ACTION_DOWN){
              switch(keyCode)
              {
              case KeyEvent.KEYCODE_BACK:
                  if(webview.canGoBack()){
                      webview.goBack();
                  }else{
                      finish();
                  }
                  return true;
              }
  
          }
          return super.onKeyDown(keyCode, event);
      }
  }
  </code></pre>
  
  <p>If possible can I set the time for the splashscreen to view as long as the url is loaded without giving time?</p>
  
  <p>The second attempt</p>
  
  <pre><code>public class MainActivity extends Activity {
  WebView webview;
  private boolean isSplashOn = true;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
  
      webview.setBackgroundColor(0);
      webview.setBackgroundResource(R.drawable.activity_splash);
  
      webview = (WebView)findViewById(R.id.output);
      webview.getSettings().setJavaScriptEnabled(true);
      webview.getSettings().setLoadsImagesAutomatically(true);
      webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
      webview.getSettings().setAppCacheEnabled(false);
      webview.setWebViewClient(new WebViewClient(){
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
              view.loadUrl(url);
  
              if(url.startsWith("tel:")) { 
                  Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
                  startActivity(intent); 
                  return true;
              }
              return false;
  
          }
  
          public void onPageFinished(WebView view, String url) {
              if(isSplashOn) { 
                  webview.setBackgroundDrawable(null);             
                  webview.setBackgroundColor(0);
  
                  isSplashOn = false;
              }
  
              super.onPageFinished(view, url);
          }
      }
              );
      webview.loadUrl("http://www.example.com");
  }
      public boolean onKeyDown(int keyCode, KeyEvent event) {
          if(event.getAction() == KeyEvent.ACTION_DOWN){
              switch(keyCode)
              {
              case KeyEvent.KEYCODE_BACK:
                  if(webview.canGoBack()){
                      webview.goBack();
                  }else{
                      finish();
                  }
                  return true;
              }
  
          }
          return super.onKeyDown(keyCode, event);
      }
  
  
  }
  </code></pre>
  
  <p>Guys. Still the problem is't solved. Need some help</p>