Hi Pushpa.,
Sorry ! After very Long.
Currently , Am getting the same problem as you mentioned here. Did you find
any Solution for this ??
Note : My code with AUDIO_FOCUS regular implementation works on some
devices, and does not work on few HTC and Samsung devices.
Thanks in advance.
- Ganesh
On Tuesday, June 19, 2012 at 12:56:31 AM UTC-7, pushpa wrote:
>
> Hi all,
>
> I am developing an application, where i need to capture the timestamp of
> music starts and ends. For that have used 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 ");
>
> }
>
> }
> onAudioFocusChange function get called when i play the music, am getting
> "audio focus lossed" message instead of gain message and I checked the
> focusChange value it is -1. Also listener will be called only once i.e when
> i opened the music first time. Listener is not called If music player is
> closed and opened again. Why is this so? Do i need to add any permission?
> I had surfed a lot but not get the proper solution Please anybody could
> explain?
>
> Thanks
> Pushpa
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.