title: What's the place of this code about urls in webview?
body: <p>I want to add this code to my java file:</p>
  
  <pre><code>webView.setWebViewClient(new WebViewClient(){
     public boolean shouldOverrideUrlLoading(WebView view, String url) {
         if (url != null &amp;&amp; url.startsWith("http://")) {
             view.getContext().startActivity(
                 new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
             return true;
         } else {
             return false;
         }
     }
  }
  </code></pre>
  
  <p>But I don't know where. This is my java file:
      package sherdle.donald.duck.app;
      import android.app.Activity;
      import android.os.Bundle;
      import android.view.Window;
      import android.webkit.WebChromeClient;
      import android.webkit.WebView;
      import android.webkit.WebViewClient;
      public class WebPageLoader extends Activity
      {
      WebView webview;</p>
  
  <pre><code>final Activity activity = this;
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
  super.onCreate(savedInstanceState);
  this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
  setContentView(R.layout.main);
  webview = (WebView) findViewById(R.id.webview);
  webview.getSettings().setJavaScriptEnabled(true);
  webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
  webview.getSettings().setSupportMultipleWindows(true);
  webview.getSettings().setPluginsEnabled(true);
  
  webview.setWebChromeClient(new WebChromeClient() {
      public void onProgressChanged(WebView view, int progress)
      {
          activity.setTitle("Loading...");
          activity.setProgress(progress * 100);
  
          if(progress == 100)
              activity.setTitle(R.string.app_name);
      }
   });
  
   webview.setWebViewClient(new WebViewClient() {
  
  
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url)
      {
          view.loadUrl(url);
          return true;
  
      }
     });
  
  
  
   webview.loadUrl("http://www.sherdle.com/apphosting/dd");
   }
  
   @Override
   public void onBackPressed (){
      if(webview.canGoBack()) webview.goBack();
      else super.onBackPressed();
   }
   }
  </code></pre>
  
  <p>I'm new to android and  I need much help for everything I do. Thanks for your help.</p>
  
  <p>I've got already this now:
      package sherdle.donald.duck.app;
      import android.app.Activity;
      import android.os.Bundle;
      import android.view.Window;
      import android.webkit.WebChromeClient;
      import android.webkit.WebView;
      import android.webkit.WebViewClient;
      public class WebPageLoader extends Activity
      {
      WebView webview;</p>
  
  <pre><code>final Activity activity = this;
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
  super.onCreate(savedInstanceState);
  this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
  setContentView(R.layout.main);
  webview = (WebView) findViewById(R.id.webview);
  webview.getSettings().setJavaScriptEnabled(true);
  webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
  webview.getSettings().setSupportMultipleWindows(true);
  webview.getSettings().setPluginsEnabled(true);
  
   webview.setWebChromeClient(new WebChromeClient() {
      public void onProgressChanged(WebView view, int progress)
      {
          activity.setTitle("Loading...");
          activity.setProgress(progress * 100);
  
          if(progress == 100)
              activity.setTitle(R.string.app_name);
      }
   });
  
  
  
   webview.setWebViewClient(new WebViewClient() {
  
  
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url)
      {
          view.loadUrl(url);
          return true;
  
      }
   });
  
   webview.setWebChromeClient(new WebChromeClient(){
     public boolean shouldOverrideUrlLoading(WebView view, String url) {
         if (url != null &amp;&amp; url.startsWith("http://")) {
             view.getContext().startActivity(
                 new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
             return true;
         } else {
             return false;
         }
     }
  
    webview.loadUrl("http://www.sherdle.com/apphosting/dd");
    }
  
  
  
   @Override
   public void onBackPressed (){
      if(webview.canGoBack()) webview.goBack();
      else super.onBackPressed();
   }
   }
  </code></pre>
  
  <p>But I get this error on my LoadUrl line:
  Multiple markers at this line
      - Syntax error, insert "AssignmentOperator Expression" to complete 
       Expression
      - Syntax error, insert ";" to complete FieldDeclaration
      - Syntax error, insert ")" to complete MethodInvocation
      - Syntax error, insert "}" to complete ClassBody
      - Syntax error, insert ";" to complete Statement
      - Syntax error on token(s), misplaced construct(s)</p>