Nicola Gallazzi
Nicola Gallazzi

Reputation: 8723

FusedLocationProviderClient keeps showing "Searching gps" notification

I would like to ask a clarification about the meaning of the "Searching gps" notification. I have a simple app that tries to retrieve user position via FusedLocationProviderClient with this code:

val fusedLocationClient = LocationServices.getFusedLocationProviderClient(activity as Activity)
fusedLocationClient.lastLocation
                .addOnSuccessListener { location: Location? ->
                    mMap.isMyLocationEnabled = true
                    // other trivial stuff here
                }.addOnFailureListener {
                    // showing an error here
                }

Even when last location is retrieved android keeps showing the "Searching gps" notification (Ricerca gps in the screenshot below). As far as you know, this means that app is still searching for gps updates (and so draining battery) or is a simple message to notify the user that the app is using the gps? Thanks for the clarification, my device is a Xiaomi Redmi 5 Plus (MiUI)

enter image description here

Upvotes: 1

Views: 978

Answers (1)

Mike
Mike

Reputation: 771

I'm not 100% sure I understand the question, but I'll take a stab here. I think one of two things is going on:

  1. The notification is being explicitly shown by the MyFoody app and it's that app's responsibility to hide the notification once it no longer needs to be shown. You'd need to take care of clearing that notification in the listener's success and failure functions you've defined. Are your listeners being called? Do they clear the notification?

OR

  1. It may be that Xiaomi has modified Android to show that notification on behalf of your app while it's retrieving location(s). If that's the case, then you'd need to figure out why this Xiaomi-modified Android version still thinks your app is trying to get a location. It could also just be a bug on Xiaomi's part, but I'd consider that as a last resort.

Upvotes: 2

Related Questions