I am beginner in Android and I have a problem with GPS in the Dalvik Emulator.
I added hardware gps support on AVD and after booting I checked Use GPS Satellites in
Settings -> Location & Security -> Use GPS Satellites.
I enable Use GPS Satellites but there is no indication that GPS is turned on. There is no satellite indicator at the top of the screen.
I tried to send coordinates to the emulator via DDMS (on a simple application) and it still doesn't work.
Have you requested location/location updates in your app? If you haven't, the GPS won't get enabled until some application requests location from it, even though it's turned on.
Try sending coordinates manually:
from DDMS view > Emulator Control Tab > any lat & any long > SEND
if your app is listening to changes, it should work
Related
I'm struggling to simulate not having gps/location or poor/slow gps location.
I'm trying to simulate and test what happens if my location request times out.
(Yes, I've tried the microwave, and I don't own a basement ðŸ˜)
There's no way to do that right now. Star the feature request to encourage Google's engineers to add it:
Android Public Tracker > App Development > Android Studio > Emulator > Allow simulating no location available.
Try finding an area of a building with poor or no cell tower signal and turn off wifi to disable wifi based location service.
I've had good luck with going down into the basement of our building with wifi turned off to delay location positioning.
Just saw your edit about no basement. On one of my older phones, I could open the cover and disconnect the antennae. Don't know if you can still do that on modern phones.
In AOSP there is libhardare library which contains interface to the GPS driver - gps.h. Using this interface you can get access to GPS driver on low level (C++), turn on GPS and get current location of the device.
On the Internet there are several projects, that use this GPS interface. For example, this one created by kanru. This code works almost perfectly - I could connect to GPS driver and get correct location.
But I ran into a problem. If you turn on GPS driver using kanru project and after awhile turn on GPS via standard method (in GUI), then C++ program will suddenly stop receive information from GPS driver. At the same time in GUI you can see that GPS is On and you can start Google Maps or any other GPS-related application and get your coordinates.
I tried to restart GpsInterface, turn off and on GPS driver via hw_device_t pointer, even restart whole C++ executable - no effect.
After restart of the program GPS driver change status to GPS_STATUS_ENGINE_ON and then - silence.
Also I tried to change the order of actions. I turned on GPS in GUI, launched Google Maps and waited several minutes till I got my location. Then I started my C++ program. It successfully connected to GPS driver and started to get location data. Meanwhile GUI "lost" connection with GPS driver.
I tried to test my program on several devices with Android 4.2 and 5.1 and get same problem on the most of them. Only on Samsung S6 with Android 5.1 my program was able to work perfectly under all conditions.
It seems like on some devices GPS driver configured so that it can work with only one data consumer.
Perhaps someone faced a similar problem?
I'm using Google Play Services to get the current location of the user. Basically I use the codes at http://www.androidhive.info/2015/02/android-location-api-using-google-play-services/ to get the location. So herein lies my problem:
1) I can get the current user location on my Xperia Mini (Running ICS) without any problem. If I didn't enable the GPS, the location that I'd receive (expectedly) isn't that accurate, but I will still get it. And if I enable the GPS, I would (again, expectedly) receive a much more accurate location.
2) But when I tried running my app on my Zenfone C (Running KitKat), if I didn't enable location, I would never get any location. getLastLocation and onLocationChanged will always return null. Only after I enable location, I'd get the location. But after I disable location and tried to getLastLocation again, it will again, return null.
The situation that occurs on my Zenfone C puzzles me, because from my understanding, even if we didn't enable location/GPS, we would still be able to get the current location from the mobile network or wifi triangulation, because that's what happening with my Xperia Mini, and I thought that should be the standard for all Android devices? Or is the enable location on/off on some Android devices have some other meaning? Perhaps on some device, when location is turned off, there's no way we can get the location. Can anyone here shed some light on this?
Thanks
There's no way for the device to get new locations once the location mode is set to off, but it's possible that the one device had a cached location from when the location mode was set to on.
Network location (Power saving mode on some Android versions) needs to be enabled to get a location from mobile data or WiFi. Note that if you use the toggle button, it enables/disables both network location and GPS (High Accuracy mode). You can use the sub-modes to enable only one location mode (Power Saving for Network only, or GPS only).
For more info, take a look at the screenshots in this answer.
Is there a recognized problem with geolocation via the default browser in Android 2.3.4 Gingerbread?
On an HTC G2 android 2.3.4, the default browser does not appear to use the GPS satellites to determine location. As a result, the location the browser sends to the app is off by a mile or so. Yes, the GPS and wi-fi were both on in the phone. We turned wi-fi off and got the same (bad) result.
Is there some voodoo that can be done to get the default browser in 2.3.4 to do proper geolocation?
On an iPhone 3s geolocation with the very same browser app works perfectly. The following link starts the Gmap4 app (I am the developer) and shows your location on the Google 'Hybrid" map:
http://www.mappingsupport.com/p/gmap4.php?mylocation=on
I believe this is not a browser problem, but a phone specific issue. If you are getting a position off by a mile, for sure the position has been acquired from wifi.
When you start the map, it tries to get the LastKnownLocation, and if it's to old it reverts to wifi position. Now, if you turn wifi off, the position acquiried using wi-fi will remain available as a recent LastKnownLocation and will be used to position the map again.
Until you get a better position from GPS this one will be used.
At least some phones discard the LastKnownLocation when you restart them. You can try it, with wifi off, to see what happens.
Regards.
I want to turn on the Network Location ("Wireless networks" - Location determined by Wi-fi and/or mobile networks). Is this possible?
In my application, I can force 3g connection (only in Android 2.3+, I have problems with WRITE_SECURE_SETTINGS on Android 2.2) and GPS Location.
Thanks,
You can do it via root methods if you must, however, I would recommend prompting the user in most cases.
See Android get location or prompt to enable location service if disabled for prompting. I'm really not sure about the root method but it is documented somewhere on the XDA-Forums I'm sure.