java.lang.Object | |
↳ | com.google.android.gms.cast.framework.SessionManager |
A class that manages Session
instances. The application can attach a SessionManagerListener
to be notified of session events.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a
SessionManagerListener to monitor events from any type of Session
instance. | |||||||||||
Adds a
SessionManagerListener to monitor events from a Session instance whose
class is sessionClass . | |||||||||||
Ends the current session.
| |||||||||||
Returns the current session if it is an instance of
CastSession , otherwise returns
null . | |||||||||||
Returns the currently active session.
| |||||||||||
Removes the
SessionManagerListener . | |||||||||||
Removes the
SessionManagerListener . | |||||||||||
Starts a session.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Adds a SessionManagerListener
to monitor events from any type of Session
instance.
Parameters | |
---|---|
listener |
SessionManagerListener |
Throws | |
---|---|
NullPointerException |
If listener is null . |
IllegalStateException |
If this method is not called on the main thread. |
Adds a SessionManagerListener
to monitor events from a Session
instance whose
class is sessionClass
.
Parameters | |
---|---|
listener |
SessionManagerListener |
sessionClass |
Class |
Throws | |
---|---|
NullPointerException |
If listener or sessionClass are null . |
IllegalStateException |
If this method is not called on the main thread. |
Ends the current session.
Parameters | |
---|---|
stopCasting |
boolean : Should the receiver application be stopped when ending the current Session. |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the current session if it is an instance of CastSession
, otherwise returns
null
.
Returns | |
---|---|
CastSession |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the currently active session. Returns null
if no session is active.
Returns | |
---|---|
Session |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Removes the SessionManagerListener
.
Parameters | |
---|---|
listener |
SessionManagerListener : The SessionManagerListener to be removed. |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Removes the SessionManagerListener
.
Parameters | |
---|---|
listener |
SessionManagerListener : The SessionManagerListener to be removed. |
sessionClass |
Class |
Throws | |
---|---|
NullPointerException |
If sessionClass is null . |
IllegalStateException |
If this method is not called on the main thread. |
Starts a session. The sender app should call this method after the app is launched by an implicit intent fired by a component outside the app, such as Google Home app. We recommended calling this method in onResume() instead of onCreate() because onCreate() is called only when the app launches. If the app is running when the intent is fired, it will be brought to the foreground and onCreate() will not be called.
public class MyActivity extends Activity { ... @Override protected void onResume() { ... Intent intent = getIntent(); // You need define your own intent filter and figure out how to check if the intent is // for joining a cast session. if (intentIsForStartingSession(intent)) { CastContext castContext = CastContext.getSharedInstance(this); castContext.getSessionManager().startSession(intent); } ... } }
Parameters | |
---|---|
startSessionIntent |
Intent : The intent that is used to start the app and ask it to join a cast
session. The intent contains necessary information for starting a session, such as the
route ID, device name, session ID, etc. This information is set by the component that fires
the intent.
|