Is it possible to retrieve whether there is any current navigation running in google maps or not? Suppose my app launches google maps,but i don't to launch if google navigation is in active state. Can we get this state..?
Thanks!!
Is it possible to retrieve whether there is any current navigation running in google maps or not? Suppose my app launches google maps,but i don't to launch if google navigation is in active state. Can we get this state..?
Thanks!!
What you're looking for is a bit tricky and depends heavily on another application's behavior. There are 2 different approaches comming to my mind without any guarantee:))
Acquire Notification Access permission and check if Google Maps is showing any notification related to navigation or not (which is a little bit sensitive asking user giving you this permission and may not work if user had prevented the Google Maps from sending notifications, but who does that?) You can take a look at this How to read all the coming notifications in android
Acquire Accessibility Permission and record user's behavior all the time, and when you've seen google maps in current activity, set a flag telling you that navigation was running or not (this permission is very sensitive and I don't suggest it also I guess it takes more effort) https://developer.android.com/guide/topics/ui/accessibility/service
Also, you might be able to do something using App Usage permission but I can't think about any tricky solutions using this. You can also check for some broadcasts that Maps might send while starting/ending navigation, but I don't think it does.
Finally, I'm not sure if Google Play is fine with what you want to do, I guess checking another application's state is not acceptable in most cases.