Is it possible to change the function of the physical button, even with the app in the background?

Asked

Viewed 92 times

1

Would you like to change the function of a physical button, for example the volume, by clicking the button, bottom or top, if it is possible to perform a function other than changing the volume of the device? Is that possible? If so, is there an example?

Ps.: With the Activity on the screen I did what I wanted, I wonder if it is possible and how to do even with the app in background.

1 answer

2


It seems to me not possible, however for some certain cases like Google Play Music (service stream music), he uses the KEYCODE_VOLUME_DOWN and KEYCODE_VOLUME_UP to decrease and increase the volume of the music you are playing, regardless of whether the app is open or not. However, whether you like it or not, you do not escape the issue of volume, which in itself is in relation to music. You can research a little about the VolumeProviderCompat added to the SDK by Google from API 22. Maybe a limitation is the Android version. But you can be sure, maybe you have a long way to go to get there.

Look at these questions:

  • I’ll search, thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.