{"id":4257,"date":"2021-11-12T20:07:40","date_gmt":"2021-11-12T12:07:40","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4257"},"modified":"2022-04-08T18:43:30","modified_gmt":"2022-04-08T10:43:30","slug":"handle-application-switch","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/android-toolkit\/handle-application-switch\/","title":{"rendered":"Handle Application Switch from Foreground to Background: Android SDK &#8211; Video API"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Moving Application to Background<\/h3>\n\n\n\n<p><strong>Class<\/strong>: <code>EnxRoom<\/code><\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>public void stopVideoTracksOnApplicationBackground(<\/code> <code>localMuteState,<\/code> <code>remoteMuteState )<\/code> <\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li><code>localMuteState<\/code>&nbsp;\u2013 Boolean. Set to&nbsp;<em>false<\/em>&nbsp;to pause Local Video Stream and <em>true<\/em>&nbsp;to continue publishing on switching the application to the background.<\/li><li><code>remoteMuteState<\/code>&nbsp;\u2013 Boolean. Set to&nbsp;<em>false<\/em>&nbsp;to pause Remote Video Stream,&nbsp;<em>true<\/em>&nbsp;to continue receiving on switching the application to the background.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ When application goes to Background\nboolean localMuteState = true;\nboolean remoteMuteState = true;\n\nroom.stopVideoTracksOnApplicationBackground( localMuteState, remoteMuteState );<\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Moving Application to Foreground<\/h3>\n\n\n\n<p><strong>Class:<\/strong> EnxRoom<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>public void startVideoTracksOnApplicationForeground( <\/code> <code>localUnmuteState, remoteUnmuteState<\/code> <code>)<\/code> <\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li><code>localUnmuteState<\/code>&nbsp;\u2013 Boolean. Set to <em>true<\/em> to resume publishing Local Video Stream if stopped while switching the application to the background.<\/li><li><code>remoteUnmuteState<\/code>&nbsp;\u2013 Boolean. Set to <em>true<\/em> to resume receiving Remote Video Streams if stopped while switching the application to the background.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ When application comes back to Foreground \nboolean localUnmuteState = false;\nboolean remoteUnmuteState = false;\n\nroom.startVideoTracksOnApplicationForeground(localUnmuteState, remoteUnmuteState);  <\/pre>\n\n\n\n<p><strong>Note:<\/strong> 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. <\/p>\n\n\n\n<p>Ref: <a aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/developer.android.com\/guide\/topics\/media\/sharing-audio-input#pre-behavior\" target=\"_blank\">https:\/\/developer.android.com\/guide\/topics\/media\/sharing-audio-input#pre-behavior<\/a><\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>\u2190 <a href=\"..\/handle-audio-device-updates\/\"><\/a><a href=\"..\/handle-audio-device-updates\/\">Handle Audio Device Updates<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-center\"><a href=\"..\/\">Index<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-right\"><a href=\"..\/detect-local-audio\/\">Detect Local Audio<\/a> \u2192<a href=\"\/developer\/how-to-use\/\"><\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&nbsp;\u2013 Boolean. Set to&nbsp;false&nbsp;to pause Local Video Stream and true&nbsp;to continue publishing on switching the application to the background. remoteMuteState&nbsp;\u2013 Boolean. Set to&nbsp;false&nbsp;to pause Remote&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3740,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ub_ctt_via":""},"featured_image_src":null,"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"featured":false,"featured-large":false},"uagb_author_info":{"display_name":"vcxdevwpadmin","author_link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/author\/vcxdevwpadmin\/"},"uagb_comment_info":0,"uagb_excerpt":"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&nbsp;\u2013 Boolean. Set to&nbsp;false&nbsp;to pause Local Video Stream and true&nbsp;to&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4257"}],"collection":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/comments?post=4257"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4257\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/3740"}],"wp:attachment":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/media?parent=4257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}