Android Question android.,media.AudioManager - setWiredDeviceConnectionState

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi All

I need to get some help converting some java to B4A. Here the link http://stackoverflow.com/questions/33422325/how-to-hide-headset-icon


It nedd to uses reflection as mentioned in the link.

Here's the code:

B4X:
AudioManager manager =(AudioManager) aContext.getSystemService(Context.AUDIO_SERVICE);

try{int deviceType =AudioSystem.DEVICE_OUT_WIRED_HEADSET;
// turn off headset
int state =0;
Class<?> cl =Class.forName("android.media.AudioManager");
Method method = cl.getMethod("setWiredDeviceConnectionState",newClass[]{Integer.TYPE,Integer.TYPE,String.class}); 
method.invoke(manager,newObject[]{ deviceType, state,"device"});}

catch(Exception e)

{ iLog.error("disableHeadset, exception {}",ExceptionUtils.getStackTrace(e));}

Thanks

John.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Mmm....thanks steve, maybe the HTC M9 has it in it build. I will ahve a route around myself. Thalk to you soon, btw, nice tunes on sound cloud ;)
 
Upvote 0
Top