• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hardware Button Notification outside of Activity or View

 
Ron McLeod
Bartender
Pie
Posts: 1050
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a working Android Push-to-Talk application which I am now enhancing to support a hardware-based PTT button. I am working with Motorola LEX 700 handsets, and found that onKeyDown() and onKeyUp() report the PTT button as KEYCODE_BUTTON_L1 - the left trigger button on a game controller.

My application consists of an Activity, a BroadcastReceiver, and three Services. The Activity is only a UI and it used to select the PTT channel, adjust the volume, see the various statuses, etc. It also has a large touch target used as a soft PTT button. The BroadcastReceiver listens for changes in the access network connectivity. One of the Services acts as the main controller and contains all of the application logic. The other two services are used for managing network IO and managing the device's audio resources.

It was trivial to watch for key events for hardware button and perform the same actions as when the touch target was pressed and released. The application can now use the hardware PTT button.

Now for my problem. Key events are only observable in an Activity (or View), and only while the the Activity (or View) has focus. I want to be able to use the hardware PTT button without the UI Activity running, or when the UI is not in focus. I am looking for any ideas how I might to be able to accomplish this.

Also, I did notice is what when my Activity was not in focus, that the hardware button presses got caught by a default handler - PhoneFallbackEventHandler - which printed a debug message that made me think that it is sending-out an Intent while the button was pressed and released. If this is the case, then I could probably catch that with my BroadcastReceiver.

06-10 15:23:29.224: D/PhoneFallbackEventHandler(654): PTT key DOWN, raising key down intent..
06-10 15:23:30.052: D/PhoneFallbackEventHandler(654): PTT key UP, raising key up intent..


I don't see anything like it in the standrd list of broadcast intents. Is there an easy way to discover it somehow?

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds rather specialized, you may have to dig into the Android source to see what is happening. The class and its usage can be found via http://androidxref.com/4.4.3_r1.1/search?refs=PhoneFallbackEventHandler&project=frameworks
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if it is one of the intents available on all systems. I think you can get a list of all the intents here:
<android sdk install path>/platforms/android-<api level>/data/activity_actions.txt

One of them might be triggered when the button is pushed. Not sure which - there are lots of them.
 
Ron McLeod
Bartender
Pie
Posts: 1050
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like they are not using the AOSP version of PhoneFallbackEventHandler - I'll keep digging.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic