I'm trying to develop an app that recognizes when a paired bluetooth keyboard's key is pressed and wakes up the app with certain action. The bluetooth device in particular is the Selfie Remote Shutter (this one, no ads intended: http://www.ebay.es/itm/like/361219097614) and it's recognized by the device as a bluetooth keyboard. It sends two different events which the SO in Android identifies as key volume up pressed and enter key pressed.
I've declared a receiver for my app and tried to listen to every bluetooth action in order to identify the command sent from the keyboard to my device, capture that event and trigger certain method in my app, even if it's not open.
I don't know how to achieve this, since when the app is opened, I can override the onKeyDown event and recognize which "key" has the bluetooth keyboard pressed, but can't figure how to achieve that with the app closed. Maybe some intent-filter?
Thanks in advance!
Related
I am developing a simple app for a 4G flip phone that will emulate a home button press (and show the launcher) when the phone's mic key or camera key is pressed while the phone's InCall Activity is topmost. (There is no home button on this phone, and the inability to return to the home screen is really frustrating.) When i use adb to send an intent calling the homescreen to the front while in call, it works, but I am trying to make an app for it so that i can do it on the go.
My trouble is assigning the app to be launched by a key press (the camera key or the mic key) while the native InCallActivity is on top. Can I do this via the XML for a reciever, and how? or do I need a service that scans for a keypress? And is what I am want potentially considered malware?
In short, can this be achieved safely and efficiently, and how?
I want to create an app that is not usable by the user but performs some functionality outside the app, the app just run in the foreground and listen to the press of android hardware/software buttons, the likes of Power button, home button, volume up and down. It triggers a call when for instance, the volume up button is pressed down for 5 secs and notification appears.
I have checked solutions like this
Intercepting the back button
How to override the behavior of the volume buttons in an Android application?
But this solutions have something to do with the user accessing the app directly, i mean to perform this functionalities you have to be on the app which i don't want.
The app was suppose to be run on a smart watch which runs android OS. I was thinking if i can perform this on android phone, it should be easier on the smart watch.
Note:
The App is for targeted users, who will be trained to understand that behavior.
For now, I just want to display a "button pressed!" message when I press any button (volume or the call button) on a paired bluetooth headset (LG HBM-770). I've tried the exact method here (this is the code I'm using): Android - registering a headset button click with BroadcastReceiver with no luck, including the suggested fixes. Hours of google searching only point to that type of code. Bluetooth permission is enabled in the manifest.
If I press the call button now, it seems to never get to my app, instead it brings up the menu that asks you to choose which app to handle it (voice search, google voice, etc). If I hold down the bluetooth call button, my phone calls the last dialed number. If I try to replace the Intent filter type with ACTION_POWER_DISCONNECTED, it works flawlessly when I disconnect power, so it seems that the code from that point on works fine.
It would be nice if I could use no filter at all, and just have a Toast pop up displaying the ID of ANY action received, so I know what exactly the buttons look like to the phone.
Prssing call button on bluetooth headset will trigger certain AT commands(check in Hands Free Spec) to phone which phone will take care, ex: when pressed call button for long duration, headset will send an AT command for call redial and so are the other usecases.
Intents and the methods provided in the link are for the button pressed on the phone.
Some new Android devices have a mute button like Iphone. Its an actual physical button that allows you to mute an incoming call instead of long pressing the volume down hardware control or the pressing the power button.
my question: What is the keycode event for this or how can i capture it so i can get my app to respond to it ?
I think you're looking for KeyEvent.KEYCODE_MUTE. Note that no flagship Android devices have this button, so you are left to the mercy of whether or not the manufacturer's OS actually sends this event or not.
I read many answers on this topic and this is what i have understood
It is not possible to get any hardkey (home,menu,back,etsc ) press events from a service. It is not delivered to any service
For key camera button and media control broadcast events are sent if these applications are not already in the foreground.
So i need to conclude that it is not possible to launch an app by pressing a hardkey or a combination of hardkeys ie ( like home key 2 times or menu key and then back key ) ?
If this is the case how is samsung launching Vlingo when home key is pressed 2 times.
How this functionality is added to samsung galaxy
thanks a lot for your time and help
The Service Can not get the KeyEvent.
Sumsung can do it directly with the system rom. But we can not.