• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Hardware Button Notification outside of Activity or View

 
Sheriff
Posts: 4646
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 4646
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems like they are not using the AOSP version of PhoneFallbackEventHandler - I'll keep digging.

Thanks.
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic