public interface ScreencastSession
ScreencastSession
to receive callbacks and provide information needed for the screencast Service
.
The implementation class must have a constructor without argument. The SDK will call that constructor to instantiate a new instance.Modifier and Type | Interface and Description |
---|---|
static interface |
ScreencastSession.SessionListener
ScreencastSession.SessionListener provides interface for developer to notify screencast service upon different methods. |
Modifier and Type | Method and Description |
---|---|
Notification |
getNotification()
Called when the screencast
Service started in foreground and you have to provide customized
Notification to indicate the screencast is running. |
NotificationChannel |
getNotificationChannel()
Called when the screencast
Service tries to call
NotificationManager.createNotificationChannel(NotificationChannel) based on your
customized NotificationChannel here. |
void |
onSessionCreate(Context context,
ScreencastSession.SessionListener listener,
Bundle bundle)
Called when
ScreencastSession is created. |
void |
onSessionDestroy()
Called when the screencast
Service is destroyed. |
void |
onStreamManagerInitComplete(com.google.android.gms.tasks.Task<StreamManager> task)
Called when
StreamManager.initialize(Identity, Bundle) is completed. |
void onSessionCreate(Context context, ScreencastSession.SessionListener listener, Bundle bundle)
ScreencastSession
is created.context
- the context from screencast Service
listener
- interface to notify the screencast Service
bundle
- Bundle
sent by StreamManager.initialize(Identity, Bundle)
Notification getNotification()
Service
started in foreground and you have to provide customized
Notification
to indicate the screencast is running. This method will be called only once
after initialized
. After this, you could invoke
ScreencastSession.SessionListener.updateNotification(Notification)
by the ScreencastSession.SessionListener
received
from onSessionCreate(Context, SessionListener, Bundle)
to update Notification
.
Note: for android 8.0, you MUST implement Notification.Builder#setChannelId(String)
for your customized Notification
, otherwise you'll get the thrown RuntimeException
with description invalid channel for service notification when screencast Service
calls Service.startForeground(int, Notification)
.Service
ScreencastSession.SessionListener.updateNotification(Notification)
,
getNotificationChannel()
NotificationChannel getNotificationChannel()
Service
tries to call
NotificationManager.createNotificationChannel(NotificationChannel)
based on your
customized NotificationChannel
here. This method will be called right after
onSessionCreate(Context, SessionListener, Bundle)
.
Alternatively, you could call NotificationManager.createNotificationChannel(NotificationChannel)
to create a notification channel by yourself. After this, you could specify this channel
for your customized Notification
to be delivered on.
Note: for android 8.0, you MUST implement this method for handling
NotificationManager.createNotificationChannel(NotificationChannel)
along with the implementation
of Notification.Builder#setChannelId(String)
, otherwise you'll get the thrown RuntimeException
with description invalid channel for service notification when screencast Service
calls Service.startForeground(int, Notification)
or
NotificationManagerCompat.notify(int, Notification)
.NotificationManager.createNotificationChannel(NotificationChannel)
,
getNotification()
,
ScreencastSession.SessionListener.updateNotification(Notification)
void onStreamManagerInitComplete(@NonNull com.google.android.gms.tasks.Task<StreamManager> task)
StreamManager.initialize(Identity, Bundle)
is completed.task
- the result, you could get the StreamManager
if task succeeded.void onSessionDestroy()
Service
is destroyed. You have to clear UI and resources about
MediaProjection
.Service.onDestroy()