Getting the name of the application with a change in focal length

I can not find anything related to figuring out which application received audio focus. I can correctly determine from my application what focus change was, but not from any other application. Is there a way to determine which application got the focus?

"What do I want to do?"

I managed to record the internal sound, whether it be music or voice. If I am currently recording audio regardless of the source, I want to determine which application has taken notice in order to determine what my application needs to do next.

I am currently using AudioManager.OnAudioFocusChangeListener for my application to stop recording internal sounds after changing focus, but I want the application name in the spotlight.

+3
source share
3 answers

Short answer: There is no good solution ... and Android probably intended to do this.

: , AudioManager API ( API) , Audio Focus. AudioManager AudioService, . API, AudioService . , AudioManager , API . , / .

, , MediaFocusControl, - AudioService .

: , UsageStats. , , ~ 500 , AudioFocus, . , .

. , , . .

+1

dumpsys audio, , . dumpsys media_session.

, , , dumpsys media.audio_flinger. .

+2

Source: https://habr.com/ru/post/1681669/


All Articles