[android-developers] OnAudioFocusChangeListener is not working as expected
Hi all,
OnAudioFocusChangeListener, and request for AUDIO_GAIN event. Below is my code.
public class AudioManagerExample extends Activity implements OnAudioFocusChangeListener{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
int result = am.requestAudioFocus(this,AudioManager.STREAM_MUSIC,AudioManager.AUDIOFOCUS_GAIN);
if(result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
Log.d("AudioManager", "Request Granted");
}
@Override
public void onAudioFocusChange(int focusChange) {
if(focusChange == AudioManager.AUDIOFOCUS_GAIN)
Log.d("AudioManager", "Inside on audio focus gained " );
else if(focusChange == AudioManager.AUDIOFOCUS_LOSS)
Log.d("AudioManager", "Inside on audio focus lossed ");
}
}
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home