Ejemplo n.º 1
0
  /**
   * Called upon user click. Attempts open mopubnativebrowser links in the device browser and all
   * other links in the MoPub in-app browser.
   */
  @VisibleForTesting
  void handleClick(final List<String> clickThroughTrackers, final String clickThroughUrl) {
    makeTrackingHttpRequest(clickThroughTrackers, getContext(), BaseEvent.Name.CLICK_REQUEST);

    if (clickThroughUrl == null) {
      return;
    }

    broadcastAction(ACTION_INTERSTITIAL_CLICK);

    if (Intents.isNativeBrowserScheme(clickThroughUrl)) {
      try {
        final Intent intent = Intents.intentForNativeBrowserScheme(clickThroughUrl);
        Intents.startActivity(getContext(), intent);
        return;
      } catch (UrlParseException e) {
        MoPubLog.d(e.getMessage());
      } catch (IntentNotResolvableException e) {
        MoPubLog.d("Could not handle intent for URI: " + clickThroughUrl + ". " + e.getMessage());
      }

      return;
    }

    Bundle bundle = new Bundle();
    bundle.putString(MoPubBrowser.DESTINATION_URL_KEY, clickThroughUrl);

    getBaseVideoViewControllerListener()
        .onStartActivityForResult(MoPubBrowser.class, MOPUB_BROWSER_REQUEST_CODE, bundle);
  }
 @Override
 protected void performAction(
     @NonNull final Context context,
     @NonNull final Uri uri,
     @NonNull final UrlHandler urlHandler)
     throws IntentNotResolvableException {
   final String errorMessage = "Unable to load mopub native browser url: " + uri;
   try {
     final Intent intent = Intents.intentForNativeBrowserScheme(uri);
     Intents.launchIntentForUserClick(context, intent, errorMessage);
   } catch (UrlParseException e) {
     throw new IntentNotResolvableException(errorMessage + "\n\t" + e.getMessage());
   }
 }
    @Override
    protected void performAction(
        @NonNull final Context context,
        @NonNull final Uri uri,
        @NonNull final UrlHandler urlHandler)
        throws IntentNotResolvableException {
      Preconditions.checkNotNull(context);
      Preconditions.checkNotNull(uri);

      final String chooserText = "Share via";
      final String errorMessage = "Could not handle share tweet intent with URI " + uri;
      try {
        final Intent shareTweetIntent = Intents.intentForShareTweet(uri);
        final Intent chooserIntent = Intent.createChooser(shareTweetIntent, chooserText);
        Intents.launchIntentForUserClick(context, chooserIntent, errorMessage);
      } catch (UrlParseException e) {
        throw new IntentNotResolvableException(errorMessage + "\n\t" + e.getMessage());
      }
    }