How handle headphone button clicks in Java (computer)? No smarthphones related - java

There's a way to handle headphones button clicks in computer (not smartphone) with Java?
The usage is very similar to Android, which by pressing the button some event is fired.
There's not much info about this, then I thought a way to perform this could be interpret the bytes of the moment of the click, and based this, do something. This "could works" but I don't know if something changes by the button click in a computer, as happens in smartphones.
So is possible handle headphones clicks in computer?

Related

How to detect long presses of the volume key in a service?

I want to detect long presses in volume key in a service. Here are my options:
A) Let the user control volume from the lock screen
I wan't to detect if the user has held down the volume button in a service while the screen is off. I already tried (for 2 days) doing it with contentObserver, but the problem is that contentObserver detects volume changes, and volume doesn't change when the screen is off. Is there any way I can let the user control volume from the lock screen?
B) Detect long press for volume button from service
How can I do this? Are there any broadcast receiver's that I can use while the screen is off? Is there a way to implement the dispatchKeyEvent in a service?
I have seen this, but for me the second answer doesn't work in the background. I think the easiest way would be option A because I already have everything set up for when the user changes volume, so can I let the user control volume from lock screen? If not, is there anything else I can do?
Thanks so much,
Ruchir

How combine two long press buttons

I am a beginner in programming android.
Is there any way to combine two long press buttons with an Android service and react to that?
I want to combine two long press buttons (home & volume down ) for activate wifi even if the phone is locked.
thanks.
Rather than connecting to the long press listener..
Connect to the button press listener.
Check when the button is pressed down, and when it is lifted up.
Measure the time between these 2 events. Was it long enough to be classed as a long press?
Were both buttons pressed down long enough at the same time?..
If you want to trigger while they are down still, just ensure the up event hasnt fired yet after 2 seconds for example.

Screen notifications for user

Please, I guess how it is called: an on-screen floating message with small arrow, they used to show to user what button to push when he sees the program for first time. They are usually with text "press this button to..." or "here you can get this.."
How to implement it in android application?
edit: I implemented some buttons on screen, and they say that it is not clear what they are for. I want to show user, when he (she) run the program after update, that this is a button and it is for...
maybe u could make a a whole new UI over ride for floating display or make a
activity fully transparent with a limited window size
and over lap it over ur previous activity

Detecting whether the camera button has been pressed using J2ME

I am trying to develop an application in which I want to know when the camera button(if the phone has one),has been pressed for feature phones like Series60 using J2ME.I dont want to take a snapshot or take a video.I just want to know when the hardware button has been pressed.
I have been unable to find a proper way for this.Your help is greatly appreciated.
Create a canvas, listen for keypresses and output all events to the screen. If no event occurs when you press the camera key then you can't do it.

Android: Display a message during a call

I have a program that makes a phone call when a user clicks on a button. The user will need to provide some information very fast to the person who answers the call(ie GPS coordinates). The problem that I am having is that, once the user clicks on the call button, they cant go back to my application.
I want to know if it possible to bring my application to the front (without hanging up the call) or to display a message until the user clicks the ok button... or something like that. I tried toast notification but they disappear and I want them to stay until the user decides to close it.
look up startActivityForResult() and see if you can hook into the calling code.

Categories

Resources