I have implemented support in my application for the new audio
features provided in the Froyo methods:

registerMediaButtonEventReceiver
unregisterMediaButtonEventReceiver

requestAudioFocus
abandonAudioFocus

These are all working fine when running on an Android 2.2 (Froyo)
device.

I have successfully used reflection for the methods:

registerMediaButtonEventReceiver
unregisterMediaButtonEventReceiver

so that the same application can run on any Android version from 1.5
to 2.2 when using these methods.

However, I am having trouble trying to use reflection for the methods:

requestAudioFocus
abandonAudioFocus

because these methods require an OnAudioFocusChangeListener parameter
which is unknown on Android devices running 1.5 to 2.1.  Because the
parameter type that must be passed into these methods is unknown and
also because my application has to have an instance of the
OnAudioFocusChangeListener object I am having trouble making
reflection work.

I can't figure out how to use the AudioManager.class.getMethod call
when it needs a parameter of type OnAudioFocusChangeListener.  I also
can't figure out how to define my instance of
OnAudioFocusChangeListener so that the application can be loaded on a
device running Android 1.5 through 2.1 without getting a Force Close
message while it is loading.

I have searched a lot of forums and haven't found any examples of how
to get reflection to work with these new Froyo audio APIs.

Can someone who better understands the use of reflection for
supporting new APIs without breaking the application's ability to
continue to run on older Android versions help me with some examples
for how to do this?

-- 
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

Reply via email to