title: Android Studio - Webview - shouldOverrideUrlLoading - Do not open web browser
body: <p>I developed a Webview app with Android Studio but when the user clicks a link from a web page in the WebView, Android is opening the default web browser.
  I already checked on Android Developers API Guides how to do but it does not work ;( on my app ... Guides Link: <a href="http://developer.android.com/guide/webapps/webview.html#HandlingNavigation" rel="nofollow">Handling Page Navigation</a></p>
  
  <p>Who know how to use the "shouldOverrideUrlLoading() method" and how to insert it in my actual app?</p>
  
  <p>Thanks</p>
  
  <p>// MainActivity.Java</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>package com.blabla.blabla;
  
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.app.Application;
  import com.parse.Parse;
  import com.parse.ParseInstallation;
  
  
  public class MainActivity extends ActionBarActivity {
      private WebView mWebView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mWebView = (WebView) findViewById(R.id.activity_main_webview);
          WebSettings webSettings = mWebView.getSettings();
          webSettings.setJavaScriptEnabled(true);
          mWebView.loadUrl("http://www.blablablablablabla.com/");
  
          Parse.initialize(this, "ID Blablabla",
                  "ID Blablabla");
          ParseInstallation.getCurrentInstallation()
                  .saveInBackground();
      }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>// activity_main.xml</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;WebView
          android:id="@+id/activity_main_webview"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
      
  &lt;/RelativeLayout&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>// Android Manifest.xml</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.blabla.blabla" &gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
  
      &lt;permission android:protectionLevel="signature"
          android:name="com.blabla.blabla.permission.C2D_MESSAGE" /&gt;
  
      &lt;uses-permission
          android:name="com.blabla.blabla.permission.C2D_MESSAGE" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
  
  
          &lt;service android:name="com.parse.PushService" /&gt;
          &lt;receiver android:name="com.parse.ParseBroadcastReceiver"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
                  &lt;action android:name="android.intent.action.USER_PRESENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;receiver android:name="com.parse.ParsePushBroadcastReceiver"
              android:exported="false"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.parse.push.intent.RECEIVE" /&gt;
                  &lt;action android:name="com.parse.push.intent.DELETE" /&gt;
                  &lt;action android:name="com.parse.push.intent.OPEN" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;receiver android:name="com.parse.GcmBroadcastReceiver"
              android:permission="com.google.android.c2dm.permission.SEND"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
                  &lt;category android:name="com.blabla.blabla" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
  
  
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;</code></pre>
  </div>
  </div>
  </p>