Search code examples
androidandroid-activitymedia-player

Detect when a non-application Activity has been called


I am trying to use a theme tune throughout all my activities. From other Stack Overflow questions it has been suggested that a Service is the correct way to do this. In order to stop the theme tune from playing I need to detect when an activity is executed that isn't part of my application.

Is there any way to do this?


Solution

  • Can't you just use onPause() and onResume(), etc for all your activities and keep track of whether they're still being used or not and send a message to the service or something? I don't think you can tell when other apps are being used that elegantly but I may be very wrong...

    There's also onAudioFocusChange(etc) which lets you detect if something else is trying to play music...