Update AudioFocusHelperImpl.java
This commit is contained in:
parent
67d418f2c3
commit
85110242ad
1 changed files with 7 additions and 20 deletions
|
@ -19,32 +19,19 @@ public class AudioFocusHelperImpl implements AudioManager.OnAudioFocusChangeList
|
||||||
private static final Log log = PlatformUtil.getLog(AudioFocusHelperImpl.class);
|
private static final Log log = PlatformUtil.getLog(AudioFocusHelperImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requestFocus(Context context, int streamType)
|
public boolean requestFocus(Context context, int streamType) {
|
||||||
{
|
|
||||||
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
if (((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get())
|
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this, streamType,
|
||||||
{
|
((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get()?
|
||||||
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this, streamType, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
|
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT:
|
||||||
}
|
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK );
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean abandonFocus(Context context, int streamType)
|
public boolean abandonFocus(Context context, int streamType)
|
||||||
{
|
|
||||||
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
if (((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get())
|
|
||||||
{
|
{
|
||||||
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this);
|
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioFocusChange(int focusChange)
|
public void onAudioFocusChange(int focusChange)
|
||||||
|
|
Loading…
Reference in a new issue