In my android application, I succeed with turning on/off gps dynamically whenever required. But I am struggling with hide the gps icon in status bar when turn on gps. How can I do it?
NOTE: I also succeed with hiding whole status bar by making full screen. But I want to hide only gps icon.
You cannot do this. The status bar icon is controlled by the system and it will not allow third party apps to hide it when GPS is on. This is for security reasons as well. Any rogue app could secretly perform malicious operations using the user's location without the user knowing about it if s/he has no indication that GPS is active.
Why would you hide GPS icon?
I think this is a bad idea, since users want to know whether their GPS is active or not.
This would allows applications to snoop users position without them being aware of that fact, which is NOT a good practise. And this is why your app requires a permission to access phone location.
if you have sdk source file, it's easy:
modify NotificationManagerService.java
in methed enqueueNotificationInternal, add a flag (db file or create a file in /data/) ,when the gps application try to send notification, block it(refer to the packagename).
but if you do not have one ....
sorry ,i don't know.
I too got same problem, means when I am asking for gps to give location updates then it will show that gps icon, so if you remove those updates calling like locationmanager.removeupdates(locationListener), then it will remove that gps icon in status bar
Related
I want to create a app which send users current location when user click on send button .
If gps is on than it will send the location, if gps is off then it automatically start the gps and then send location...
Manifest permissions is not a problem, problem is that it should not pop up dialogue to start gps when it is off..
Please help me, i really need help..
I want to know that is it possible?
If yes then a provide useful link or code or any kind of hint..
Thank you :)
There are a lot of other threads discussing this, and the general consensus is that it shouldn't be possible, even though on some versions there are exploits that allow it.
However, this doesn't seem to be ethical, since you are violating your users privacy by not allowing them to choose whether or not they want to share their location.
How can I enable or disable the GPS programmatically on Android?
Turning on and off GPS programmatically in android 4.0 and above?
ICS Android enable gps programmatically?
I am starting activity with application context when screen is locked. However Status bar is not usable, doesnt get dropped down. Is there any way to make status bar and notifications usable when screen is locked ? (ICS-Android)
No, this cannot be done. This is a security feature of android, if the notification bar could pulled down while the user has the device locked, then it opens the user to security issues as personal information may be in the notification bar such as missed calls, text messages and emails etc.
Well.. GravityBox has an option to allow this.
However I'd be interested on what file you'd have to mod inside the SystemUI/res folder in order to make it work without Gravitybox...
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?
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.
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.
I have a problem with proximity alerts on Android.
Here's what I'm doing in my app
Fetch list of locations from server.
Add proximity alerts of these locations (now GPS icon shows in status bar).
When user enters the area launch my app activity.
Problem is that, when I uninstall my app with proximity alerts added it still shows GPS icon in status bar. User can turn off all proximity alerts in app but it doesn't solve my problem. I also now that it's impossible to do anything during uninstall process. Any ideas?
//EDIT:
Only way to get rid of GPS icon after app uninstall is to restart the device.
Report bug to Android developers. LocationManager should handle such use case (this case is easy to forget and apparently Android developers forgot about that).
As a workaround you can try to create a service which will exist as long as you need proximity alert. I'm hoping that service is gracefully closed on removal and not just killed. In such case you will remove proximity alert. You have to try it to be sure that this is good solution.
i need to hide the GPS icon from the status bar when my service uses it. I've been making some research and found that it's not possible programatically.
but i found that it is possible if my phone is rooted by installing something on the memory card. anyone can help with the root thing and if it is possible, can it be done programatically without going through the root thing.
thx a lot :D
No, it's not possible to do it with the public API.
Yes, you will need a rooted phone, but that's not enough. You will need to modify services.jar (and perhaps framework.jar also) in order to check whether your service is working or not.
Alternatively, as suggested by Someone Somewhere, you can hide the status bar altogether.
As a side note after the comment below, I would not set up the service to run all the time as it seems you're planning to do. Instead, I would register a BroadcastReceiver to read the SMS and start an Intent upon reception of a specific message. You could hide the status bar in that moment. See this for more details: Can we delete an SMS in Android before it reaches the inbox?