SessionProvider
Stay organized with collections
Save and categorize content based on your preferences.
An abstract base class for performing session construction. The SDK uses a subclass of
SessionProvider
to construct CastSession
internally. If your app wants to support other types of Session
then you should subclass this class. Subclasses must implement
createSession(String)
and
isSessionRecoverable()
, which will be called by the Cast SDK during the lifecycle
of the session. All methods must be called from the main thread.
Protected Constructor Summary
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Protected Constructors
protected SessionProvider (Context
applicationContext, String category)
Constructs a SessionProvider
with a category string. The category uniquely identifies a Session
created by this provider.
Parameters
applicationContext |
The application Context of the calling app. |
category |
The category string used to create Session . |
Public Methods
public abstract Session
createSession (String sessionId)
Constructs a new Session
.
This method is called by the SDK to create a new session.
public final String getCategory ()
public final Context
getContext ()
Returns the application Context
used to construct this instance.
public abstract boolean
isSessionRecoverable ()
Returns true
if a previously constructed session can be resumed.
Subclasses should check any persisted information about the previous session, such as a
session ID, and return true only if it is possible to resume that session. This method
is called by the SDK when it tries to resume a previously saved session.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eSessionProvider\u003c/code\u003e is an abstract base class for creating and managing Cast sessions in Android applications.\u003c/p\u003e\n"],["\u003cp\u003eIt allows developers to support custom session types beyond the default provided by the Cast SDK.\u003c/p\u003e\n"],["\u003cp\u003eSubclasses must implement \u003ccode\u003ecreateSession()\u003c/code\u003e to construct new sessions and \u003ccode\u003eisSessionRecoverable()\u003c/code\u003e to determine if previous sessions can be resumed.\u003c/p\u003e\n"],["\u003cp\u003eThe SDK uses the provided category string to uniquely identify sessions created by a specific \u003ccode\u003eSessionProvider\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAll \u003ccode\u003eSessionProvider\u003c/code\u003e methods should be called from the main thread to ensure thread safety.\u003c/p\u003e\n"]]],["`SessionProvider` is an abstract class for session construction. Subclasses must implement `createSession(String)` to create new sessions and `isSessionRecoverable()` to determine if a session can be resumed. The `SessionProvider` is constructed with an application context and a unique category string. It has methods to get the category and application context, and all method calls must occur on the main thread. It's used by the SDK to manage `CastSession` and allows for other session types.\n"],null,["# SessionProvider\n\npublic abstract class **SessionProvider** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nAn abstract base class for performing session construction. The SDK uses a subclass of\n[SessionProvider](/android/reference/com/google/android/gms/cast/framework/SessionProvider)\nto construct [CastSession](/android/reference/com/google/android/gms/cast/framework/CastSession)\ninternally. If your app wants to support other types of [Session](/android/reference/com/google/android/gms/cast/framework/Session)\nthen you should subclass this class. Subclasses must implement [createSession(String)](/android/reference/com/google/android/gms/cast/framework/SessionProvider#createSession(java.lang.String)) and [isSessionRecoverable()](/android/reference/com/google/android/gms/cast/framework/SessionProvider#isSessionRecoverable()), which will be called by the Cast SDK during the lifecycle\nof the session. All methods must be called from the main thread. \n\n### Protected Constructor Summary\n\n|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [SessionProvider](/android/reference/com/google/android/gms/cast/framework/SessionProvider#SessionProvider(android.content.Context,%20java.lang.String))([Context](//developer.android.com/reference/android/content/Context.html) applicationContext, [String](//developer.android.com/reference/java/lang/String.html) category) Constructs a [SessionProvider](/android/reference/com/google/android/gms/cast/framework/SessionProvider) with a category string. |\n\n### Public Method Summary\n\n|--------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Session](/android/reference/com/google/android/gms/cast/framework/Session) | [createSession](/android/reference/com/google/android/gms/cast/framework/SessionProvider#createSession(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) sessionId) Constructs a new [Session](/android/reference/com/google/android/gms/cast/framework/Session). |\n| final [String](//developer.android.com/reference/java/lang/String.html) | [getCategory](/android/reference/com/google/android/gms/cast/framework/SessionProvider#getCategory())() Returns the category string for this [SessionProvider](/android/reference/com/google/android/gms/cast/framework/SessionProvider). |\n| final [Context](//developer.android.com/reference/android/content/Context.html) | [getContext](/android/reference/com/google/android/gms/cast/framework/SessionProvider#getContext())() Returns the application [Context](//developer.android.com/reference/android/content/Context.html) used to construct this instance. |\n| abstract boolean | [isSessionRecoverable](/android/reference/com/google/android/gms/cast/framework/SessionProvider#isSessionRecoverable())() Returns `true` if a previously constructed session can be resumed. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nProtected Constructors\n----------------------\n\n#### protected **SessionProvider** ([Context](//developer.android.com/reference/android/content/Context.html) applicationContext, [String](//developer.android.com/reference/java/lang/String.html) category)\n\nConstructs a [SessionProvider](/android/reference/com/google/android/gms/cast/framework/SessionProvider)\nwith a category string. The category uniquely identifies a [Session](/android/reference/com/google/android/gms/cast/framework/Session)\ncreated by this provider. \n\n##### Parameters\n\n| applicationContext | The application Context of the calling app. |\n| category | The category string used to create [Session](/android/reference/com/google/android/gms/cast/framework/Session). |\n|--------------------|-----------------------------------------------------------------------------------------------------------------|\n\nPublic Methods\n--------------\n\n#### public abstract [Session](/android/reference/com/google/android/gms/cast/framework/Session)\n**createSession** ([String](//developer.android.com/reference/java/lang/String.html) sessionId)\n\nConstructs a new [Session](/android/reference/com/google/android/gms/cast/framework/Session).\nThis method is called by the SDK to create a new session. \n\n#### public final [String](//developer.android.com/reference/java/lang/String.html) **getCategory** ()\n\nReturns the category string for this [SessionProvider](/android/reference/com/google/android/gms/cast/framework/SessionProvider). \n\n#### public final [Context](//developer.android.com/reference/android/content/Context.html)\n**getContext** ()\n\nReturns the application [Context](//developer.android.com/reference/android/content/Context.html)\nused to construct this instance. \n\n#### public abstract boolean\n**isSessionRecoverable** ()\n\nReturns `true` if a previously constructed session can be resumed.\nSubclasses should check any persisted information about the previous session, such as a\nsession ID, and return true only if it is possible to resume that session. This method\nis called by the SDK when it tries to resume a previously saved session."]]