Intents { public static Intent intentForNativeBrowserScheme(@NonNull final Uri uri) throws UrlParseException { Preconditions.checkNotNull(uri); if (!UrlAction.OPEN_NATIVE_BROWSER.shouldTryHandlingUrl(uri)) { throw new UrlParseException("URL does not have mopubnativebrowser: } if (!"navigate".equals(uri.getHost())) { throw new UrlParseException("URL missing 'navigate' host parameter."); } final String urlToOpenInNativeBrowser; try { urlToOpenInNativeBrowser = uri.getQueryParameter("url"); } catch (UnsupportedOperationException e) { MoPubLog.w("Could not handle url: " + uri); throw new UrlParseException("Passed-in URL did not create a hierarchical URI."); } if (urlToOpenInNativeBrowser == null) { throw new UrlParseException("URL missing 'url' query parameter."); } final Uri intentUri = Uri.parse(urlToOpenInNativeBrowser); return new Intent(Intent.ACTION_VIEW, intentUri); } private  Intents(); static void startActivity(@NonNull final Context context, @NonNull final Intent intent); static Intent getStartActivityIntent(@NonNull final Context context,
            @NonNull final Class clazz, @Nullable final Bundle extras); static boolean deviceCanHandleIntent(@NonNull final Context context,
            @NonNull final Intent intent); static boolean canHandleApplicationUrl(final Context context, final Uri uri); static boolean canHandleApplicationUrl(final Context context, final Uri uri,
            final boolean logError); static Intent intentForNativeBrowserScheme(@NonNull final Uri uri); static Intent intentForShareTweet(@NonNull final Uri uri); static void showMoPubBrowserForUrl(@NonNull final Context context,
            @NonNull Uri uri); static void launchActionViewIntent(Context context, @NonNull final Uri uri,
            @NonNull final String errorMessage); static void launchIntentForUserClick(@NonNull final Context context,
            @NonNull final Intent intent, @Nullable final String errorMessage); static void launchApplicationUrl(@NonNull final Context context,
            @NonNull final Uri uri);  }
@Test public void intentForNativeBrowserScheme_shouldProperlyHandleEncodedUrls() throws UrlParseException { Intent intent; intent = Intents.intentForNativeBrowserScheme(Uri.parse("mopubnativebrowser: assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(intent.getDataString()).isEqualTo("http: intent = Intents.intentForNativeBrowserScheme(Uri.parse("mopubnativebrowser: assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(intent.getDataString()).isEqualTo("http: intent = Intents.intentForNativeBrowserScheme(Uri.parse("mopubnativebrowser: assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(intent.getDataString()).isEqualTo("http: }
@Test(expected = UrlParseException.class) public void intentForNativeBrowserScheme_whenNotMoPubNativeBrowser_shouldThrowException() throws UrlParseException { Intents.intentForNativeBrowserScheme(Uri.parse("mailto: }
@Test(expected = UrlParseException.class) public void intentForNativeBrowserScheme_whenNotNavigate_shouldThrowException() throws UrlParseException { Intents.intentForNativeBrowserScheme(Uri.parse("mopubnativebrowser: }
@Test(expected = UrlParseException.class) public void intentForNativeBrowserScheme_whenUrlParameterMissing_shouldThrowException() throws UrlParseException { Intents.intentForNativeBrowserScheme(Uri.parse("mopubnativebrowser: }