0

I want to have my music player app launch when the user gets into his car. But if he has loaded a satnav (e.g. google maps) then I would like my app to run in the background.

I already have the code launch my app when the user gets into the car. What I'd like to know is how to determine if some sort of satnav app is in the foreground.

This question explains how to tell what app is in the foreground. But given that information, how can I tell if it's a satnav or maps application, without explicitly checking a list of package names? For example, could I find out what intents the foreground application can listen to? And are there any such intents which would suggest it is a satnav application?

Thanks

Community
  • 1
  • 1
Jodes
  • 14,118
  • 26
  • 97
  • 156

1 Answers1

1

What I would do is that connect your phone to the pc and monitor the logcat. Start the Navigation application and see what activity starts (from the logcat). Take a note of the package name.

Then in your activity, when onStop is called, start a service which checks the ActivityManager and sees if the Navigation application is running or not.

hoomi
  • 1,882
  • 2
  • 16
  • 17
  • Thanks, +1 for checking logcat for packages etc. but I do not want to limit it to checking for one specific application (therefore package name). Is there any way of checking if the app is *any* maps app? – Jodes Aug 23 '14 at 11:13
  • I am not sure about that. I would guess all the navigation apps have map(s) or navigation keyword in them – hoomi Aug 23 '14 at 11:15