Reputation: 621
I need to show the GPS icon on status bar, whenever I call the get lat long function.
But now, the gps icon is shown in through out the application.
How to show/hide the GPS icon in status bar?
Upvotes: 0
Views: 7989
Reputation: 82553
No, it's not possible to do it with the public API.
To do this, not only will you need a rooted phone,but you will need to modify services.jar
(and perhaps framework.jar
also) in order to be able to hide this. In short, unless you're compiling your own version of the Android ROM, you can't really do this.
Alternatively, as suggested by Someone Somewhere, you can hide the status bar altogether.
However, if you want to make sure the GPS icon isn't shown when you aren't using it, then is means that you haven't called removeUpdates()
, and hence the system is letting the user know that their location is being monitored by an app. To remove the icon, simply call removeUpdates()
on the LocationManager
.
Upvotes: 3
Reputation: 67286
If you are willing to fetch the GPS data in only one screen you can remove/unregister Listener in onPause()
that will remove the GPS icon in the status bar. Also, you can register the Listener again inside onResume()
to get the GPS icon back when you switch to the same screen/activity again.
You can check this
example how it is done.
Also, its always a good thing to unregister the LocationListener when you are done with the GPS work as it can drain the battery too quickly which users don't like at all.
Upvotes: 0