Re: Activate GPS in source

76 views
Skip to first unread message

Simon Kenyon

unread,
Sep 19, 2012, 2:25:31 AM9/19/12
to android-...@googlegroups.com
On 09/18/12 21:15, malpunt wrote:
Hello, I would like to confirm some comments I have seen on the internet that is impossible to capture the GPS coordinates directly in the android code (Java + Google API)?!
 
I was using a code to activate in versions 2.2 and 2.3 (working perfectly), only when using the 4.0 is not working and, as the link below, I discovered that what used to be a bug.
It really is not possible? This has been fixed in 4.0? Is there another way?
 
Thanks,
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/rTBYWjvGfuUJ.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

have a look at android.location.LocationManager.getLastKnownLocation()

malpunt

unread,
Sep 21, 2012, 2:43:31 PM9/21/12
to android-...@googlegroups.com
Dear simonckenyon, you do not understand the problem. I'm managing to capture the coordinates. What I need is to activate the GPS before capturing those coordinates. My client does not accept the user having to go to settings and manually activate the GPS and then go to the system and then capture the system coordinates with the android.location.LocationManager.getLastKnownLocation ().

What am extremely frustrated is not native something like:
locationManager.setEnabled (LocationManager.GPS_PROVIDER);

Rudolf Hornig

unread,
Sep 22, 2012, 7:00:07 AM9/22/12
to android-...@googlegroups.com
That is by design. That GPS setting in the location manager is a SECURITY feature. If the user switched that off, no program should be allowed to turn that on and ONLY the user should be allowed to torn that on on the system UI. 

If you want to be able to turn it on by a random user program, then you have to have a rooted phone. The best you can do is to detect that the GPS is disabled, inform the user that theis program cannot run without the GPS and open the Location settings screen directly from the app (so the user does not have to navigate there manually). 

malpunt

unread,
Oct 2, 2012, 9:47:54 AM10/2/12
to android-...@googlegroups.com
Thanks for the reply Rudolf Hornig. I understand that Android is a configuration that can not be accessed.
 
However, I wonder if anyone knows if there will be possibility of doing this in a future version? I ask this because the sponsor is considering migrating to iOS if that is not possible. In that case I would have more time to convince him.
 
Thanks,

Rudolf Hornig

unread,
Oct 4, 2012, 10:21:00 AM10/4/12
to android-...@googlegroups.com
I'm not an authority to say anything, but I highly doubt it will change. Originally (till android 1.6 if I remember correctly) this setting was modifiable by programs and the option was explicitly removed by the android team and placed under the more secure area, exactly for this reason. I doubt they will do any turnaround, and honestly I agree with them...

I feel this is a misunderstanding. If a user says that the GPS should be DISABLED totally then this is a decision that all programs should honor. I'm not an iOS developer, but I highly doubt that once a user disables the location services any program could turn it on. This would be a big security risk...

I'm the author of "GPS Status and Toolbox" which has similar usage pattern. If GPS is essential for your program, check whether it is enabled and show the system settings with a little message asking the user to enable it...

Personally I would never touch an operating system where I cannot disable the location services... 

Or... you can require a rooted phone and you can do whatever you want :)
Rudolf
Reply all
Reply to author
Forward
0 new messages