Search code examples
androidbuttonlistenerassistant

Button listener in background to trigger activity


Recently I've started to write my own assistant, but encountered with a problem. I need to listen Push to Talk (physical) button event even when my app is on background. I know button listeners are not available within Service's, but I wonder how come Google Assistant can be triggered when there is another app on foreground ? Does anyone know what is different on that ?

Thanks


Solution

  • It seems it is very possible to do it, IF you have chance to compile your own Android version. For reference you can try imitate following class and implementations around it.

    Although, this is not only implementation and change, it also requires changes in HAL layer.

    Also I couldn't find how Google handles this. But my best guess would be either something like this or something like this.