Open GoogleCodeExporter opened 8 years ago
Please attach sample code that demonstrates this issue.
Original comment by mjo...@google.com
on 16 Jul 2012 at 6:18
I need my app to get the audio focus when tv is ruuing a channel and my app is
launched and loose focus when it goes to background. I tried it but not working
in google tv. I tried
mAudioManager.requestAudioFocus(this,AudioManager.STREAM_MUSIC,AudioManager.AUDI
OFOCUS_GAIN); It working in device.i.e music stopped as app launched. but not
worked in google tv with any parameters. Steps for audio focus are:
1.In MainApp AudioManager mAudioManager = (AudioManager)
getSystemService(Context.AUDIO_SERVICE); requestFocus();
In onresume() protected void onResume() { super.onResume(); requestFocus(); }
3.in onStop() protected void onStop(){ abandonFocus(); super.onStop();
Log.e("APPLICATION", "APPLICATION onStop");
}
4.in onDestroy() public void onDestroy(){ super.onDestroy();
//Log.e("APPLICATION", "APPLICATION onDestroy"); abandonFocus(); } 5.Methods
for AudioFocus.
/** Requests audio focus. Returns whether request was successful or not. */
public boolean requestFocus() { return AudioManager.AUDIOFOCUS_REQUEST_GRANTED
== mAudioManager.requestAudioFocus(this, AudioManager.STREAM_DTMF,
AudioManager.AUDIOFOCUS_GAIN);
}
/** Abandons audio focus. Returns whether request was successful or not. */
public boolean abandonFocus() {
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this);
}
/**
* Called by AudioManager on audio focus changes. We implement this by calling our
* MusicFocusable appropriately to relay the message.
*/
public void onAudioFocusChange(int focusChange) {
switch (focusChange) {
case AudioManager.AUDIOFOCUS_GAIN:
Log.e("AUDIOFOCUS","AUDIOFOCUS_GAIN");
break;
case AudioManager.AUDIOFOCUS_LOSS:Log.e("AUDIOFOCUS","AUDIOFOCUS_LOSS");
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:Log.e("AUDIOFOCUS","AUDIOFOCUS_LOSS_TRANSIENT");
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:Log.e("AUDIOFOCUS","AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
break;
default:
}
}
Can any one please help me in this. who did the audio focus in google tv.
Original comment by poornach...@gmail.com
on 27 Jul 2012 at 6:15
FYI: here my activity is running with transparent background view.
Original comment by poornach...@gmail.com
on 27 Jul 2012 at 7:36
Original issue reported on code.google.com by
poornach...@gmail.com
on 11 Jul 2012 at 4:09