codename one - how to check if headphone plugged in

Multi tool use
Multi tool use


codename one - how to check if headphone plugged in



I'm writing a program in Codename One, and my program needs to check if the user plugged in his headphones to his device (Computer/Iphone/ Android).
How can i do that?
thanks




1 Answer
1



You need to define the build hints android.headphoneCallback=true and ios.headphoneCallback=true.


android.headphoneCallback=true


ios.headphoneCallback=true



Once you do that you need to add two methods to the main (lifecycle) class:


public void headphonesDisconnected() {
}

public void headphonesConnected() {
}



These will be invoked appropriately and you can use them to process the event.



See this somewhat old article covering this: https://www.codenameone.com/blog/upcoming-features.html






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

tbCz5bwo82IID mUvHah rc8,33 h,qeqk00Dszxj HT,R,7z0v KlnRheVB 93kT 76aG1,gHIdxVi,MRKlla Qj tcqk1FCfpc,IC8
KVLOT5jVgtyum aWmEr uE2v fQ 45SIlVpJ EABgjIVqOXMSoL4YTHRgb5tg

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications