Storing a variable with app that has current audio focus?
Moderator: Martin
Storing a variable with app that has current audio focus?
Is there some way to find out what app currently has audio focus and store it? I'm trying to set up my Nexus to resume playing when it gets a power source, but since Spotify, Google Play, Doggcatcher, all respond a bit differently to media keys, I need to know which one was previously playing.
Re: Storing a variable with app that has current audio focus
Hi,
I'm not aware of an official API to get the current audio focus owner.
On a rooted device you can use Execute Root Command: dumpsys audio and use a script and string operations to find the last entry of the audio focus stack:
Sample Output (Android 4.3):
Regards,
Martin
I'm not aware of an official API to get the current audio focus owner.
On a rooted device you can use Execute Root Command: dumpsys audio and use a script and string operations to find the last entry of the audio focus stack:
Sample Output (Android 4.3):
Code: Select all
Audio Focus stack entries (last is top of stack):
source:android.os.BinderProxy@42b1f4e8 -- pack: com.google.android.music -- client: android.media.AudioManager@42463488com.google.android.music.playback.LocalDevicePlayback$8@42451970 -- duration: 1 -- uid: 10036 -- stream: 3
source:android.os.BinderProxy@429beae0 -- pack: com.jetappfactory.jetaudio -- client: android.media.AudioManager@42668f88o.Κ@4272b630 -- duration: 1 -- uid: 10061 -- stream: 3
...
Martin