How to add GPS signal strength bar in android?
I am trying to create a GPS signal strength bar that will gauge the accuracy of the positions (the criteria would probably be 3 lowest and 10 highest ). I would like to see it like the signal bars we have on the phones telling us how our service is. Does anyone know how to crea开发者_运维技巧te this bar?
This problem consists of two sub-problems:
1) How to obtain the GPS signal strength?
Looking at the Location object that is provided when your application has registered itself as a LocationListener, the object provides a getAccuracy()
method which returns how certain the location is.
2) How to show a strength bar?
I assume that you want to show it in the upper notification bar. As far as I know, you won't get the bar into the right part of the bar as it's system-reserved. However, you can simply create a simple Notification which shows the icon in the left part of your status bar. When the strength changes, just update the Icon of your notification and you're done.
精彩评论