use of com.amazonaws.mobileconnectors.cognitoauth.exceptions.BrowserNotInstalledException in project aws-sdk-android by aws-amplify.
the class AuthClient method launchCustomTabs.
/**
* Launches the HostedUI webpage on a Custom Tab.
* @param uri Required: {@link Uri}.
* @param activity Activity to launch custom tabs from and which will listen for the intent completion.
* @param browserPackage Optional string specifying the browser package to launch the specified url.
* Launches intent chooser if set to null.
*/
private void launchCustomTabs(final Uri uri, final Activity activity, final String browserPackage) {
try {
if (!isBrowserInstalled()) {
userHandler.onFailure(new BrowserNotInstalledException("No browsers installed."));
return;
}
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(mCustomTabsSession);
mCustomTabsIntent = builder.build();
if (pool.getCustomTabExtras() != null) {
mCustomTabsIntent.intent.putExtras(pool.getCustomTabExtras());
}
if (browserPackage != null) {
mCustomTabsIntent.intent.setPackage(browserPackage);
} else if (customTabsPackageName != null) {
mCustomTabsIntent.intent.setPackage(customTabsPackageName);
}
mCustomTabsIntent.intent.setData(uri);
if (activity != null) {
activity.startActivityForResult(CustomTabsManagerActivity.createStartIntent(context, mCustomTabsIntent.intent), CUSTOM_TABS_ACTIVITY_CODE);
} else {
Intent startIntent = CustomTabsManagerActivity.createStartIntent(context, mCustomTabsIntent.intent);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
context.startActivity(startIntent);
}
} catch (final Exception e) {
userHandler.onFailure(e);
}
}
Aggregations