title: Load scanned QR url into android webview
body: <p><em><strong></em>**See bottom for the fix to below question**</strong></p>
  
  <p>Ok everything works except for loading the url and when it tries to load the url into the webview it adds url: in front of the hyperlink. For example: url:<a href="http://google.com" rel="nofollow">http://google.com</a> and the webview won't load this of course. I have tried .replace("url:","") and .replaceAll("url:","") to no success. The SCAN_RESULT is generated using zbar barcode library. </p>
  
  <p>Main Activity</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      switch (requestCode) {
          case ZBAR_SCANNER_REQUEST:
          case ZBAR_QR_SCANNER_REQUEST:
              if (resultCode == RESULT_OK) {
  
                  String value = data.getStringExtra(ZBarConstants.SCAN_RESULT);
                  String newValue = value.replaceAll("url:", "");
  
                  Intent intent = new Intent(getApplicationContext(), WebViewActivity.class);
                  intent.putExtra("mUrl",newValue);
                  startActivity(intent);
  
                  //Toast.makeText(this, "Scan Result = " + data.getStringExtra(ZBarConstants.SCAN_RESULT), Toast.LENGTH_LONG).show();
              } else if(resultCode == RESULT_CANCELED &amp;&amp; data != null) {
                  String error = data.getStringExtra(ZBarConstants.ERROR_INFO);
                  if(!TextUtils.isEmpty(error)) {
                      Toast.makeText(this, error, Toast.LENGTH_SHORT).show();
                  }
              }
              break;
      }
  }
  </code></pre>
  
  <p>Webview Activity</p>
  
  <pre><code>public class WebViewActivity extends Activity {
  
  private WebView mWebView;
  
  @SuppressLint("SetJavaScriptEnabled")
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      String mUrl = getIntent().getStringExtra("mUrl");
      //String newMUrl = mUrl.replaceAll("url:", "");
  
      mWebView = (WebView) findViewById(R.id.activity_main_webview);
      WebSettings webSettings = mWebView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      mWebView.loadUrl(mUrl);
      mWebView.setWebViewClient(new WebViewClient());
      mWebView.setWebViewClient(new MyAppWebViewClient());
  
  }
  </code></pre>
  
  <p>WebView Client</p>
  
  <pre><code>public class MyAppWebViewClient extends WebViewClient {
  
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
      view.getContext().startActivity(intent);
      return true;
  }
  }
  }
  </code></pre>
  
  <p><strong>MainActivity (FIXED)</strong></p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      switch (requestCode) {
          case ZBAR_SCANNER_REQUEST:
          case ZBAR_QR_SCANNER_REQUEST:
              if (resultCode == RESULT_OK) {
  
                  String value = data.getStringExtra(ZBarConstants.SCAN_RESULT);
                  //The FIX IS BELOW url is case-sensitive, instead of url: it's URL:
                  String newValue = value.replace("URL:", "");
  
                  Intent intent = new Intent(getApplicationContext(), WebViewActivity.class);
                  intent.putExtra("mUrl",newValue);
                  startActivity(intent);
  
                  //Toast.makeText(this, "Scan Result = " + data.getStringExtra(ZBarConstants.SCAN_RESULT), Toast.LENGTH_LONG).show();
              } else if(resultCode == RESULT_CANCELED &amp;&amp; data != null) {
                  String error = data.getStringExtra(ZBarConstants.ERROR_INFO);
                  if(!TextUtils.isEmpty(error)) {
                      Toast.makeText(this, error, Toast.LENGTH_SHORT).show();
                  }
              }
              break;
      }
  }
  </code></pre>