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?
Related
In my android app there are certain requirements required in order to use the app (Internet access, GPS, etc.). Now I haven't really found anything dealing with this so I don't know if its a mute point or not. A user can leave your app at any time and turn things off/on on the phone. If I am checking to ensure that data access is available as well GPS in the app oncreate and onresume and just tell the user they need to switch it on, would that probably be enough? I'm thinking not. I'm thinking of redirecting the user to a new layout telling them what is missing and what needs to be done in order to use the app. This layout would also include a button for them to continue once settings are turned on. Is this a good idea or bad? I don't know if there is a better way of handling this or not so all input is appreciated. What do you do?
You might find some of your answers in Find Success on Google Play. If a user performs an action without satisfying all of the requirements, you could present a dialog explaining to the user what the requirements are and why they are necessary. You might also provide a link to redirect the user to the proper settings.
EDIT: The best practices in this situation are probably similar to Requesting Permissions at Run Time. Permissions Best Practices suggests something similar to what you are proposing, which is to show some sort of message or tutorial explaining to the user what is required and why, and then redirecting the user to the appropriate settings.
EDIT: One more example: That Android Documentation shows you how to use the Settings API to check which settings are enabled, and present the Location Settings dialog for the user to update their settings with a single tap. See Prompt the User to Change Location Settings
I want to change the GPS settings of an app by clicking the Accept button. But I can't find any reference on how to do that? I tried but security exception occurred. Is it possible?
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));You can use this
Android Guidelines have changed above version 4.0. You cannot change GPS off on programmatically for versions above 4.0.
Apps cannot enable or disable GPS programmatically, except perhaps on rooted devices. Please allow the user to do that.
I suggest you to use dialog for asking user to turn off and on the gps, and redirect to settings on ok button press.that is even better and user friendly.
Finally i got the solution, using GoogleApiClient we can enable the GPS by providing priority programmatically with out moving user to the settings page.
I'm creating an app, that heavily relies on LocationServices.
For now I'm asking user to turn them on, and everything works fine.
However, when user clicks "No", the whole point of this app goes to hell.
I can spam user to turn location services on from my Service, however I find this solution extremely non-elegant.
Is there a way to turn this setting on programatically? I don't care for additional permissions or so.
I did my research and I only got what I already did - ask user to turn on location services with a dialog etc.
Is there a way to turn this setting on programatically?
Fortunately, no, for obvious privacy and security reasons, except perhaps on rooted devices.
However, when user clicks "No", the whole point of this app goes to hell.
Then advise the user once (per run of your UI) that your app cannot function, and the user should uninstall your app.
Bear in mind that many more permissions will have this same sort of user-recovable behavior with Android M.
You simply cant , if that was possible then you can easily gather locations which is for some unethical reasons could be sold ... so for security reasons its not possible at all .
you can always force the user to click yes by making a really useful and helpful application that the user simply want to try and cant click no because it wont function at all ...
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
Assuming the device's "Use Wireless networks" and "Use GPS satellites" settings under Location is not enabled, is it possible to still retrieve the location coordinates.
Currently, the best is to redirect the user to the settings page is not enabled. I find this disruptive as needs to navigate away from the app.
If i am not mistaken, you can enable the settings programmatically (Am I correct?).
I don't need the exact coordinates, is it possible to get the cell tower ID without the settings enabled?
No. If the user doesn't want to give you his location, There is no way you can get his location.
This is a security measure and it exists for good reasons. If you try to subvert this, your app will be considered malicious.
Redirecting the user to the settings page is the best option.
Agreed - in earlier versions of android, you could programatically turn on the GPS - but more recent versions do not allow this to happen.
As Anup states - the common acceptable practice now is to redirect the user to the options page and allow the user to select the type and nature of GPS that the application is allowed to use.
Dont forget , you dont need to "leave the app" to get the user to turn on GPS, you can send them to the settings yourself:
startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
This will then come back to your app where it left off - giveing the use a seamless experience, and one which they will be familiar with from other android apps.
Setting anything programatically without asking the user first is bad practice.
What you could do is, in case you can't get a location, ask the user to turn GPS on or tell him your app won't be able to work and will close.
switching on Location settings programmatically without the users consent is impossible let alone bad practice. You can prompt the user and direct him to switch on location settings or if you program tracks the progress of the device user, you can have the program send an alert of some sort telling them that the Location setting is off.
Deep dive into location has a set of best practices for Android's LocationManager. You do not need the GPS to be activated -- in many cases, the mobile network itself gives a pretty good approximation of the location without taking up extra battery.