4

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.

15
  • Try this android.stackexchange.com/a/232252/131553
    – beeshyams
    Commented Jan 18, 2021 at 20:18
  • 1
    Thanks for the reply. I think this app does something different from what I want though. It looks like it just records screen time. I usually don't start the app but control the playback through the media controls in the notification bar. And of course I don't have my screen on while listening to a podcast.
    – user.S
    Commented Jan 18, 2021 at 21:47
  • If "audio player" is an app, I think AppOps can be used to achieve what you want. But it requires elevated privileges, root or at least ADB. Commented Jan 22, 2021 at 17:28
  • 1
    I edited the question to clarify what I meant by AudioPlayer. I checked out AppOps but it seems to only have to do with permissions.
    – user.S
    Commented Jan 23, 2021 at 16:02
  • Based on Android Developers, the media controls on Android 11's notification is using MediaSession and MediaRouter2 APIs, though I haven't tested if using such API will create a log in the logcat or not.
    – Andrew T.
    Commented Jan 23, 2021 at 16:16

0

You must log in to answer this question.

Browse other questions tagged .