How to show/hide the GPS icon in status bar? - android

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.

Related

Appinventor data triggered by GPS location

I want to create an app in appinventor which will be using gps coordinates to show some data. What I mean is that I want to make an app which will show a message whenever you go to an exact position. I already got the GPS coding that needs to be done but I'm not sure if I can save the data to somehow inside the gps. Im new at this so don't be too harsh with me! Is it even possible to do something like that in appinventor?
Unfortunately what you're describing is a service, in which your program runs in the background waiting for the GPS to hit a trigger location. App Inventor at his time does not have the capability to let you program a service.
You have to open your app manually and have it run in the background. As long as all permissions are enabled, it can then send push notifications using the appropriate block. I personally haven't experimented with what they display, but when properly done, it can show an image and text at the same time, one, or the other.
This means you could call the GPS when you reach a certain location, send a push notification with said text/image, which you can then view by the pulldown bar.
You could also have the app send yourself information via a text, replacing this with the push notification block, whenever you reach a certain latitude and longitude.

turn on/off gps without shownig icon in status bar

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

Remove proximity alerts when uninstalling app

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.

Android: Proximity Alert

I have followed this tutorial about how to use the proximity alert and how to register it.
It all works but when I close the app (with the back button, not the home-button) then the proximity alert does not work anymore. Does anyone know how to set it so that it runs in the background?
Thanks in advance!
It seems that you can not get location updates when your application is not running. Receiving location updates in the background is not a good idea since it drains battery power and the user might not be aware that the location is being tracked since the normal behavior for pressing the back button on the application is for it to close all services. If I want my application to continue running in the background, I as a user would press the home button.
Look at the model used by the "My Tracks" application.
Also see the documentation from Android on locations and usage models:
http://developer.android.com/guide/topics/location/obtaining-user-location.html
If you have informed yourself about the reasons not to have the application do this in the background but still want to run this in the background, look into Services
http://developer.android.com/reference/android/app/Service.html
They can run in the background and provide your application with data when asked.
Fundamental part of Android... Services.
http://developer.android.com/guide/topics/fundamentals/services.html
You should get it if you register for it, but keep in mind that proximity alert may not be immediate if your screen is off. If your screen is off, then location is probed for every 4 minutes as stated in the documentation.

hiding GPS notification icon from the status bar

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?

Categories

Resources