-
- All Implemented Interfaces:
-
app.moviebase.androidx.customtab.ServiceConnectionCallback
public class CustomTabActivityHelper implements ServiceConnectionCallback
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceCustomTabActivityHelper.ConnectionCallbackA Callback for when the service is connected or disconnected. Use those callbacks tohandle UI changes when the service is connected or disconnected.
public interfaceCustomTabActivityHelper.CustomTabFallbackTo be used as a fallback to open the Uri when Custom Tabs is not available.
-
Constructor Summary
Constructors Constructor Description CustomTabActivityHelper()
-
Method Summary
Modifier and Type Method Description static voidopenCustomTab(Context context, Uri uri, Runnable fallback, @Nullable() CustomTabsSession session, @ColorInt() int color)static voidopenCustomTab(Context context, CustomTabsIntent customTabsIntent, Uri uri, Runnable fallback)Opens the URL on a Custom Tab if possible. voidunbindCustomTabsService(Activity activity)Unbinds the Activity from the Custom Tabs Service. CustomTabsSessiongetSession()Creates or retrieves an exiting CustomTabsSession. voidsetConnectionCallback(CustomTabActivityHelper.ConnectionCallback connectionCallback)Register a Callback to be called when connected or disconnected from the Custom Tabs Service. voidbindCustomTabsService(Activity activity)Binds the Activity to the Custom Tabs Service. booleanhasClient()booleanmayLaunchUrl(Uri uri, Bundle extras, List<Bundle> otherLikelyBundles)voidonServiceConnected(CustomTabsClient client)Called when the service is connected. voidonServiceDisconnected()Called when the service is disconnected. -
-
Method Detail
-
openCustomTab
static void openCustomTab(Context context, Uri uri, Runnable fallback, @Nullable() CustomTabsSession session, @ColorInt() int color)
-
openCustomTab
static void openCustomTab(Context context, CustomTabsIntent customTabsIntent, Uri uri, Runnable fallback)
Opens the URL on a Custom Tab if possible. Otherwise fallsback e. g. to opening it on a WebView.
- Parameters:
context- The host activity.customTabsIntent- a CustomTabsIntent to be used if Custom Tabs is available.uri- the Uri to be opened.fallback- a CustomTabFallback to be used if Custom Tabs is not available.
-
unbindCustomTabsService
void unbindCustomTabsService(Activity activity)
Unbinds the Activity from the Custom Tabs Service.
- Parameters:
activity- the activity that is connected to the service.
-
getSession
CustomTabsSession getSession()
Creates or retrieves an exiting CustomTabsSession.
-
setConnectionCallback
void setConnectionCallback(CustomTabActivityHelper.ConnectionCallback connectionCallback)
Register a Callback to be called when connected or disconnected from the Custom Tabs Service.
-
bindCustomTabsService
void bindCustomTabsService(Activity activity)
Binds the Activity to the Custom Tabs Service.
- Parameters:
activity- the activity to be binded to the service.
-
hasClient
boolean hasClient()
-
mayLaunchUrl
boolean mayLaunchUrl(Uri uri, Bundle extras, List<Bundle> otherLikelyBundles)
-
onServiceConnected
void onServiceConnected(CustomTabsClient client)
Called when the service is connected.
- Parameters:
client- a CustomTabsClient
-
onServiceDisconnected
void onServiceDisconnected()
Called when the service is disconnected.
-
-
-
-