The following methods are used to switch the RTC application to the background and vice versa. The methods allow you to configure whether to continue streaming or pause after the switch.
Moving Application to Background
Class: EnxRoom
Method: public void stopVideoTracksOnApplicationBackground(
localMuteState,
remoteMuteState )
Parameters:
localMuteState
– Boolean. Set to false to pause Local Video Stream and true to continue publishing on switching the application to the background.remoteMuteState
– Boolean. Set to false to pause Remote Video Stream, true to continue receiving on switching the application to the background.
// When application goes to Background boolean localMuteState = true; boolean remoteMuteState = true; room.stopVideoTracksOnApplicationBackground( localMuteState, remoteMuteState );
Moving Application to Foreground
Class: EnxRoom
Method: public void startVideoTracksOnApplicationForeground(
localUnmuteState, remoteUnmuteState
)
Parameters:
localUnmuteState
– Boolean. Set to true to resume publishing Local Video Stream if stopped while switching the application to the background.remoteUnmuteState
– Boolean. Set to true to resume receiving Remote Video Streams if stopped while switching the application to the background.
// When application comes back to Foreground boolean localUnmuteState = false; boolean remoteUnmuteState = false; room.startVideoTracksOnApplicationForeground(localUnmuteState, remoteUnmuteState);
Note: To use Audio device after moving the application to background, the application must have Android foreground service otherwise the application would be unable to capture Audio input.
Ref: https://developer.android.com/guide/topics/media/sharing-audio-input#pre-behavior