I made a application that works fine on the emulator (using telnet and geo fix), but on the device the callbacks of the LocationListener are not called at all.
I already checked permission ( on manifest.xml), checked if GPS is active (it is, and works fine in google maps, and the satellite drawing shows up when my app turns on).
Someone has any clue on what may be happening?
Did you:
(1) make a release key on your machine?
(2) get a RELEASE API key from Google based on the MD5 fingerprint generated by your release key?
(3) build that Google key into your code or xml?
(4) sign your application with the release key?
Unless you remember getting a second (release) key from the Google site, that's the problem.
On second thoughts the GPS should still work, it's just that you wouldn't get the map
If your program isn't calling your onLocationChange method then you probably are inside or somewhere where you can't get a GPS signal. Try moving outside somewhere with a clear view of the sky.
Which methods have you defined in your location listener? Because the onProviderDisabled and onProiderEnabled functions should work even without a GPS signal.
The issue was indeed related to accuracy, the GPS do not work when it is not accurate.
But manually loading Wi-Fi was failing.
The correct solution is use the Criteria class, and then find the "best provider" automatically based on the Criteria. It will accept bad accuracy values, also last values when more accurate, and whatnot, mimicking the behavior of the GPS on Google Maps APP.
Related
In my app I am using FusedLocationProviderClient to get user location every time he enters the app by mFusedLocationClient.getLastLocation().addOnCompleteListener().But sometimes result is null,I am using <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> in manifest.How can I get user location even if it not so correct?Because the logic of app depends on that location,I don't need to show it on map or smth like that,just get the location.Thx in advance
Don't use getLastLocation(). There is always a chance to have it return null if it doesn't have a location currently.. Use requestUpdates or requestSingleUpdates- when the callback for those is called the location is guaranteed to be non-null. getLastLocation() should only be used as an optimization to improve speed, it cannot be relied on.
Follow the following example and your app is guaranteed to work as you wish. I have recently used this code and it is working like a charm.
Only thing you should know is that for the location updates to actually work ( to get real latitude and longitude values) you should enable "google play services". There may be several ways to do this but perhaps the simplest of all is to open "settings" on your device and probably somewhere under "security" or "permissions" (depending on your android distribution) find "google play services" and give it the permission it needs.
https://github.com/googlesamples/android-play-location/tree/master/LocationUpdates
I work in QA for an company that helps market applications. Currently I have been tasked to ensure location dependent apps function if correctly (ie if im in russia the app displays the russian content and if i change to us the app updates to the us content)
I have tried numerous items to accomplish this but get no where.
What i have tried:
Proxy. Setting this up via wifi to several locations. Both the app and the device still show my current location.
Apps: I have tried all of the following apps and they all give the same result as above.
Fake Location
AutoProxy
Fake GPS
I have enabled developer mode on the devices, and have ensured that "Mock Locations" is checked.
Use case 1:
A developer whats us to test his app which is only available in england. Google Play still sees me in US
Use case 2:
A developer releases a game where the background changes based on your location if i cant force the location change I cant verify this feature works.
Im guessing the fails so far are due to the fact that the location being called in our test apps is network location not GPS?
Any help would be awesome. Even if you could just point me in a direction.
Thank you Greatly
J
Update:
Ok, Thanks to the answers about google play and mock locations. So with those in mind lets think about it from another perspective. If the app is not calling for mock location, Is there anyway to force a mock location override? im trying to cover all the bases here, One app for sure does not use this method, so I still need to find a way around.
depending on how they are calling for the location, I would think (remember im knew here) that using a proxy would work, however as stated above, i'm not getting anywhere there either. Did try a few free proxy's from hidemyass but even the browser wouldn't work with them.
Yes, network location does not get faked by mock location providers. I don't know why not, but it only fakes GPS. In addition, your app has to request the MOCK permission to get it. If it doesn't have this permission, setting a mock location will not actually fake anything to the app. This is for security purposes, so a malicious app can't start broadcasting the wrong location to the phone.
I've tried to run Geofences sample and I've got little confunsed regarding to how it works.
Prior to go on, I've studied the new APIs and wached this video:
http://www.youtube.com/watch?v=Bte_GHuxUGc&list=WLRNCZT9Eq_HTG5jIEFxMpdqoXZBNalekx
So I jumped coding it. I thought that this API would manage the GPS position's captures automatically, in order to get my position.
So at this point raises my doubt. I've only got notified within a geofence, if I turnned my google map app on so my device starts capturing my location thru GPS.
So, what should I do to have "my app" forcing GPS use ?
I appreciate your help.
Best Regards,
Marlus
Does the location access have any dependency on activity recognition process?
In some devices i could get my activity recognition sample working only after turning on my location setting
This issue is fixed in latest update of Google Play services(4.3.23 (1069729-030)). All we need to do is replace library project "google-play-services_lib" with latest version(4.3.23 (1069729-030)). I noticed a delay of about 1 minute in AR updates if we toggle location settings, but it works.
The Activity Recognition is part of the Google Play Location API. See the docs here:
Recognizing the User's Current Activity
You can see that this is part of the Location Services offered by Play. Internally there needs to be some way to determine the speed of movement of the device - and that requires location based calculations.
Below is an extract from the Class Overview paragraph of the ActivityRecognitionClient documentation:
It only makes use of low power sensors in order to keep the power usage to a minimum.
This suggests (as the OP pointed out) that the API relies on network location, and not GPS location.
So it would make sense from a security aspect.
If I, as a user, decide I don't want to let any apps see or use my location, then I would expect the Play API to obey that decision.
Anything else, and the security is lost.
I downloaded the GeoDetection.zip file for trying out location based geofencing using the Google Play Services API that is available from the developer android website from the following link:
http://developer.android.com/training/location/geofencing.html
but when i tried to add geo fences using this app, i constantly get the error GEOFENCE_NOT_AVAILABLE
i tried to check what this error means, and i found that if location access is not available that is when i should get this message, but i checked the Location Services section on my phone and i saw that all the Location provides GPS/Wifi Location are all enabled. I am also connected to WIFI successfully. Not sure why i still get the message.
Any body else encounter this issue?..if so, do you have a fix that i could try?
Any other suggestions?.. i tried a lot of options to make sure it is capturing all the options, but there is isn't much debug information for me to proceed any further.
Thanks in advance
Are you requesting the FINE_LOCATION permission?
Remember on Android 6 and above you have to handle the permissions at run-time too.
The above error, GEOFENCE_NOT_AVAILABLE is an expected error code, to let you know that the location adapter is off and location (and geofence) will NOT be tracked anymore.
Once available again, your geofences will be active and you will get the desired callback.
Few Reasons why the triggers aren't happening :
Check if your expiry timestamp that you set in your geofence request, is still valid.
Did your device get restarted ? If yes, you need to re-register fences. (Refer documentation : Re-register geofences only when required documentation)
Is your location, set to High Accuracy mode in Device settings ?
When you re-register your fences, you should un-register them first and then only re-register.
Open Google maps and check if it's showing the right location.
Is Battery Optimisation on for your device ? This will delay geofence triggers
Is you app whitelisted for background operations (Happens in some Chinese OEM's)