java.lang.Object | |
↳ | com.google.android.gms.cast.framework.Session |
![]() |
An abstract base class representing a session with a receiver application. A session is an
end-to-end connection from a sender application to a receiver application. When the user selects
a receiver device from the media route chooser dialog, a session is created by the
SessionManager
using its corresponding SessionProvider
.
A subclass must override start(Bundle)
, resume(Bundle)
and end(boolean)
, so that
SessionManager
can call them to start, resume or end the session. Subclass must also call
the appropriate notifier methods to notify the state of the session. For example, call
notifySessionStarted(String)
when the session has been successfully started, so that the
SessionManager
will notify the rest of the app that the session has been started.
An implementation of this base class, CastSession
, is provided by the SDK to manage
connection to a Cast receiver device. This Session base class is provided so that if a sender
application supports a receiver device that is not a Cast device, it can implement a custom
session to communicate with that device, and still be able to let the SDK create the session when
the user selects that device from the media route chooser dialog.
All methods must be called from the main thread.
See also:
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a
Session with a category string. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the category associated with this
Session . | |||||||||||
Returns the unique ID for this session.
| |||||||||||
Subclass can override this method to provide a hint of how long the current session will
live.
| |||||||||||
Returns
true if the session is connected. | |||||||||||
Returns
true if the session is connecting or resuming. | |||||||||||
Returns
true if the session is disconnected. | |||||||||||
Returns
true if the session is disconnecting. | |||||||||||
Returns
true if the session is resuming. | |||||||||||
Returns
true if the session is suspended. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Subclass should override this method to provide business logic of ending a session.
| |||||||||||
Subclass should call this to notify the SDK that a session has failed to resume.
| |||||||||||
Subclass should call this to notify the SDK that a session has failed to start.
| |||||||||||
Subclass should call this to notify the SDK that a session has ended.
| |||||||||||
Subclass should call this to notify the SDK that a session has been successfully resumed.
| |||||||||||
Subclass should call this to notify the SDK that a session has been successfully started.
| |||||||||||
Subclass should call this to notify the SDK that a session has been suspended.
| |||||||||||
Subclass should override this method to provide business logic of resuming a session.
| |||||||||||
Subclass should override this method to provide business logic of starting a session.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Constructs a Session
with a category string. The category uniquely identifies
a Session
.
Parameters | |
---|---|
applicationContext |
Context :
The application Context of the calling app. |
category |
String :
The category string for this Session . |
sessionId |
String :
The session ID of an existing session, if this object will be used to resume
a session; otherwise null if it will be used to start a new session.
|
Returns the category associated with this Session
.
Returns | |
---|---|
String |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the unique ID for this session.
Returns | |
---|---|
String |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Subclass can override this method to provide a hint of how long the current session will
live. The SDK may call this method at any time to decide how long it should try to
automatically resume the session if it got disconnected unexpectedly. The default return
value is 0
.
Returns | |
---|---|
long |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns true
if the session is connected.
Returns | |
---|---|
boolean |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns true
if the session is connecting or resuming.
Returns | |
---|---|
boolean |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns true
if the session is disconnected.
Returns | |
---|---|
boolean |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns true
if the session is disconnecting.
Returns | |
---|---|
boolean |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns true
if the session is resuming. A session is considered connecting when
resuming.
Returns | |
---|---|
boolean |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns true
if the session is suspended. A session is considered connecting when is
suspended.
Returns | |
---|---|
boolean |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Subclass should override this method to provide business logic of ending a session. This method is called by the SDK when ending an active session. This method is called on the main thread and must not block.
Parameters | |
---|---|
stopCasting |
boolean :
Should the receiver app be stopped when the current session ends.
|
Subclass should call this to notify the SDK that a session has failed to resume.
Parameters | |
---|---|
error |
int
|
Subclass should call this to notify the SDK that a session has failed to start.
Parameters | |
---|---|
error |
int
|
Subclass should call this to notify the SDK that a session has ended.
Parameters | |
---|---|
error |
int
|
Subclass should call this to notify the SDK that a session has been successfully resumed.
Parameters | |
---|---|
wasSuspended |
boolean
|
Subclass should call this to notify the SDK that a session has been successfully started.
Parameters | |
---|---|
sessionId |
String
|
Subclass should call this to notify the SDK that a session has been suspended.
Parameters | |
---|---|
reason |
int
|
Subclass should override this method to provide business logic of resuming a session. This method is called by the SDK when resuming a session. This method is called on the main thread and must not block.
Parameters | |
---|---|
routeInfoExtra |
Bundle :
The extra field in the MediaRouter.RouteInfo.
|
Subclass should override this method to provide business logic of starting a session. This method is called by the SDK when starting a session. This method is called on the main thread and must not block.
Parameters | |
---|---|
routeInfoExtra |
Bundle :
The extra field in the MediaRouter.RouteInfo.
|