codename one - how to check if headphone plugged in


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.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages