In Android 11, at least in the version Google uses for their phones, all audio apps can be controlled with media buttons you see if you pull down the notifications/top/task/whatever bar.
My question is: How can I get a log of when I stop and start audio from the top bar media buttons?
The log needs to include timestamps, so I can see how long something has played for. It would preferably also include some information about what was being played, such as the title of the track or podcast. It also need to always go at least one week back in time, which seemingly rules out using
logcat the standard way.
Any way of doing it would be okay. For example:
- An app that can monitor audio plackback on the phone.
- Getting system logs through ADB.
- "System traces"?
As far as I can tell, Android destroys logs from before that last reboot, but I might be wrong about this. The log I get by running
adb logcat gives me the information I need. It seems I am only able to get logs since the last reboot though. If I can access old logs, that would be a solution to the problem and you would get the bounty for helping me achieve this.
If there is a way to know when I start and stop playing audio from within an app, I would also accept an answer that lets me get this information. I don't mind if the information comes from the media buttons or not, I just want to know when audio starts and stops playing on the device.
MediaRouter2APIs, though I haven't tested if using such API will create a log in the logcat or not.