Lines Matching full:focus
1 page.title=Managing Audio Focus
19 <li><a href="#RequestFocus">Request the Audio Focus</a></li>
20 <li><a href="#HandleFocusLoss">Handle the Loss of Audio Focus</a></li>
35 interact. To avoid every music app playing at the same time, Android uses audio focus to moderate
36 audio playback—only apps that hold the audio focus should play audio.</p>
38 <p>Before your app starts playing audio it should request—and receive—the audio focus.
39 Likewise, it should know how to listen for a loss of audio focus and respond appropriately when that
43 <h2 id="RequestFocus">Request the Audio Focus</h2>
45 <p>Before your app starts playing any audio, it should hold the audio focus for the stream
51 permanent audio focus. Request transient focus when you expect to play audio for only a short time
52 (for example when playing navigation instructions). Request permanent audio focus when you
55 <p>The following snippet requests permanent audio focus on the music audio stream. You should
56 request the audio focus immediately before you begin playback, such as when the user presses
63 // Request audio focus for playback
67 // Request permanent focus.
78 the system that you no longer require focus and unregisters the associated {@link
79 android.media.AudioManager.OnAudioFocusChangeListener}. In the case of abandoning transient focus,
83 // Abandon audio focus when playback complete
87 <p>When requesting transient audio focus you have an additional option: whether or not you want to
88 enable "ducking." Normally, when a well-behaved audio app loses audio focus it immediately
89 silences its playback. By requesting a transient audio focus that allows ducking you tell other
91 focus returns to them.</p>
94 // Request audio focus for playback
98 // Request permanent focus.
109 <p>Whenever another app requests audio focus as described above, its choice between permanent and
110 transient (with or without support for ducking) audio focus is received by the listener you
111 registered when requesting focus.</p>
114 <h2 id="HandleFocusLoss">Handle the Loss of Audio Focus</h2>
116 <p>If your app can request audio focus, it follows that it will in turn lose that focus when another
117 app requests it. How your app responds to a loss of audio focus depends on the manner of that
121 onAudioFocusChange()} callback method of they audio focus change listener you registered when
122 requesting audio focus receives a parameter that describes the focus change event. Specifically,
123 the possible focus loss events mirror the focus request types from the previous
126 <p>Generally speaking, a transient (temporary) loss of audio focus should result in your app
128 monitor changes in audio focus and be prepared to resume playback where it was paused once you?ve
129 regained the focus.</p>
131 <p>If the audio focus loss is permanent, it?s assumed that another application is now being used to
134 those events—and abandoning your audio focus. At that point, you would expect a user action
138 loss is transient and resume it when we have regained the focus. If the loss is permanent, it
139 unregisters our media button event receiver and stops monitoring audio focus changes.<p>
157 <p>In the case of a transient loss of audio focus where ducking is permitted, rather than pausing
167 lose focus, then returns it to its previous level when we regain focus.</p>
181 <p>A loss of audio focus is the most important broadcast to react to, but not the only one. The