Skip to content

Commit

Permalink
Update CustomTabsController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj committed Sep 22, 2023
1 parent 82a9e72 commit 8af5792
Showing 1 changed file with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,28 @@ public void launchUri(@NonNull final Uri uri, final boolean launchAsTwa, ThreadS
return;
}

try {
if (launchAsTwa) {
this.launchedAsTwa = true;
twaLauncher.launch(
customTabsOptions.toTwaIntentBuilder(context, uri),
null,
null,
null,
TwaLauncher.CCT_FALLBACK_STRATEGY
);
} else {
launchAsDefault(context, uri);
new Thread(() -> {
try {
if (launchAsTwa) {
this.launchedAsTwa = true;
twaLauncher.launch(
customTabsOptions.toTwaIntentBuilder(context, uri),
null,
null,
null,
TwaLauncher.CCT_FALLBACK_STRATEGY
);
} else {
launchAsDefault(context, uri);
}
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Could not find any Browser application installed in this device to handle the intent.");
} catch (SecurityException ex) {
AuthenticationException e = new AuthenticationException(
"a0.browser_not_available", "Error launching browser for authentication", ex);
threadSwitcher.mainThread(() -> failureCallback.apply(e));
}
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Could not find any Browser application installed in this device to handle the intent.");
} catch (SecurityException ex) {
AuthenticationException e = new AuthenticationException(
"a0.browser_not_available", "Error launching browser for authentication", ex);
threadSwitcher.mainThread(() -> failureCallback.apply(e));
}
}).start();
}

private void launchAsDefault(Context context, Uri uri) {
Expand Down

0 comments on commit 8af5792

Please sign in to comment.