Beispiel #1
0
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (mActivity == null) {
      return false;
    }

    final Uri uri = Uri.parse(url);
    if (Utils.divertMailtoUri(mActivity, uri, mAccount)) {
      return true;
    }

    final Intent intent;
    if (mAccount != null && !Utils.isEmpty(mAccount.viewIntentProxyUri)) {
      intent = generateProxyIntent(uri);
    } else {
      intent = new Intent(Intent.ACTION_VIEW, uri);
      intent.putExtra(Browser.EXTRA_APPLICATION_ID, mActivity.getPackageName());
      intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
    }

    boolean result = false;
    try {
      intent.setFlags(
          Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NO_ANIMATION);
      mActivity.startActivity(intent);
      result = true;
    } catch (ActivityNotFoundException ex) {
      // If no application can handle the URL, assume that the
      // caller can handle it.
    }

    return result;
  }