I´ve bought a Bluetooth headset (MOTOROLA HK200) with the intention to use the call button in a push to talk application. This way, with my application running, when I push the headset call button I want to start capturing and sending audio. However, when I push the call button for a long period of time, a new call is directly launched and Android prompts a dialog to choose the application I want to use to make the call (which is not what I want). I've already achieved something similar with a wired headset by capturing the event ACTION_MEDIA_BUTTON (1) but I don't get the same result with the Bluetooth headset call button.
I've been looking examples for a long time but I haven't found the solution.
Thanks for your help,
Pressing headset for a long time issues a AT command to phone to redial the last number. I think its calls the BluetoothHandsfree.redial()(in packages/apps/Phone) method to call last call which is called when phone receives BLDN command(or maybe another AT command).
Related
I just started creating apps, and now I want to know how to build something that
helps me to start an app, by execercising a volume down/up press during the sleepmode of my phone.
I think that it will need an OnReceive Method or something that works like a onclicklistener but i cant figure it out.
Greetings
In a normal way its not possible to catch your volume down/up receiver when your phone is locked(straight-forward). However here in this discussion they are trying to control volume when phone is locked via some other way - LINK
However you can launch your application when the phone is unlocked by using volume down/up event or combination using the receiver logic. You can register for "android.intent.action.MEDIA_BUTTON" to receive the broadcastreceiver.
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.
I am working on an android app and i wanted to know if it is possible to receive the numbers or DTMF tone or any such related data at the called party's phone, that the calling party is typing on his/her phone while the phone of the called party is ringing.
Just to make the question more clearer, consider this scenario with two people A and B :
Caller A is calling B.
B's phone is ringing.
A types a sequence or a single digit on his phone while it is still ringing.
Those digits are received at B's phone.
Based on what digit / what sequence it is, an action will be triggered at B's phone (Through my app).
I just wanted to know if the above scenario or anything equivalent or remotely like the same is possible.
Thank you
No. First, we have no access to the in-call audio stream, except perhaps if the phone is in speakerphone mode. Second, I am not aware of any Android device that plays the audio of the incoming call over top of the ringing where the user has not picked up the phone.
I've made some research concluded that afaik I can't have an Android service for key events capture. But - maybe some will have any workaround. I have a player application, which i want to play/pause using a special button on my earphones (included for my samsung galaxy S). This is button for reciving and ending phone calls set on phones cable.
Ive tested this button - it equals KeyCode.KEYCODE_BUTTON_B const (79). And it can be handled when my player is on screen, but I'd like to play/pause also when my phone is locked (with screen off). Do You think this is possible?
For call reciving I think android uses a trick: when someone calling, the screen goes active, and the call-reciving activity can handle key events (I think - this is how it's work, but I can be wrong).
I have no idea - how to play/pause my app using this button.
I don't think there is any real good way to achieve what you want to do from the application level. However one possible solution I can come up with is this:
Listen for screen off and on Intents. When you receive SCREEN_OFF start up a "blank" activity that does nothing but listen for your button press and passes it along to your music service.
When you recieve SCREEN_ON finish() this blank activity.
I don't know for sure that this approach will work, but I used something similar to be able to listen for volume button presses while the screen was off.
Note about listening for SCREEN_OFF and SCREEN_ON intents. When I did this I had to set the filter for my receiver in java code rather than in the manifest. For some reason when I set the intent filter from the manifest it wasn't receiving those intents properly.
All,
I have searched for an answer to this, but I'm not getting anything exact... It's my first time writing an Android app, so please be gentle :)
I'm pretty bummed about the minimal headset support in Android - unlike e.g. iPhone, it only natively seems to support a single button, so no volume control on headset compatibility. Additionally, if I'm listening to music and a call comes in, the OS pauses the music automatically, but the headset button still functions ONLY as a media button - I can't use it to answer/end the call. If I answer the call via the screen and press the headset button, the music starts again, but the call continues...
I'd like to create a 'middleman' app that can pick up that the headset button has been pressed (via Keyevent.KEYCODE_HEADSETHOOK) and can then determine whether to perform the default ACTION_MEDIA_BUTTON action (toggle play/pause in my chosen media player) or, if there is an incoming call, pause the music and answer the phone (and then, when pressed again, end the call and restart the media player). Perhaps even check for ACTION_MULTIPLE on the headset button to assign different options (ACTION_MEDIA_NEXT, ACTION_MEDIA_PREVIOUS etc.). Perhaps also be able to determine whether different buttons on the headset have been pressed (if the headset is e.g. a fancy iPhone headset) and 'translate' those button presses into the appropriate ACTION_MEDIA_*). This might not be possible if the OS can't tell the difference between different buttons, obviously.
Obviously such an app would have to receive the intent with a high enough priority that it would be able to abort the broadcast before the current media player gets it.
I've been tinkering with creating assorted BroadcastReceiver classes and intent filters etc., but part of the problem is that the bult-in Android emulator that comes with Eclipse doesn't seem to have the ability to simulate a user plugging in the headset and/or subsequently clicking the headset button. Therefore, every time I get somethign that looks promising, I have to put it onto my actual phone and try it out - time-consuming and a hassle.
3 questions then:
Am I missing somethign obvious - is this a real problem and if so, has it already been solved?
If it IS a problem, is it possible to write such a middleman app?
Are there any other Android emulators that can check for headset-related activities?
Thanks,
Rory
i´ve already written exactly this kind of app. Its called like the topic of this thead: Headset Button Controller ;-)
http://www.androidpit.com/en/android/market/apps/app/com.kober.headset/Headset-Button-Controller
Cheers Christoph