Google Play Services LocationClient returns null - android

I am new to android and I want to get the current location for which I am referring to the link http://developer.android.com/training/location/retrieve-current.html which shows the use of Google Play Services.
To start with I have downloaded the sample LocationUpdates from the above link and I am using an emulator(AVD with target Google API Inc,API Level 17,Platform 4.2.2).
I am trying to get the current Location and it returns null.It uses LocationCLient and makes a call mLocationClient.getLastLocation().
Check is made if Google Play Services are available by using GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); here it returns 0(success).
I have enabled the Location access in the emulator:Wifi and GPS Satellites.
Please help me to know what is mising so that I get the current location.
Thanks

Try opening Google Maps on the emulator once so that the Google Play Services can update, then enable "Access Location" from the Google Settings application under "Google Location".
After doing this I was able to manually push GPS-locations to the device using the emulator controls and accessing them from the LocationClient.

If both your WiFi and GPS services are enabled,is your device actually connected to WiFi too? If not, your WiFi service won't be working, and the location provider will fall back to GPS. GPS will not be quick enough to get your location which lead the value (getLastLocation()) to be null sometimes.

Related

Using Google play service can i get latest location in offline mode ( FusedLocationProviderApi)

using google play service we can get getLastLocation() which are using fused location provider to retrieve the device's last known location.
using change location i can set setPriority()
know to get current location form google doc
Once you have connected to Google Play services and the location services API, you can get the current location settings of a user's device
so my question is if i am not connected to network (internet connection) can i use the latest location of user not the last location the current location
yes sure you can get latest update location using GoogleApiClient. check this.
It has worked for me.Thank you.

Check if Google Play location service is enabled

How can I check if Google Play location services are enabled? None of the answers on StackOverFlow address the issue directly. I'm not interested in last location, whetever or not GPS and network providers are enabled in system or anything, I just want to know, if Google Play location services are enabled.
I tried using getLocationAvailability().isLocationAvailable(), but it returned true (after location was retrieved for first time) even after I disabled Google Play location services, which then prevented the application from working correctly.
Image of setting (first one on the image, ignore arrow):
http://img.wonderhowto.com/img/38/89/63522883742111/0/psa-googles-keeping-tabs-your-location-heres-stop-them.w654.jpg
Is there any way to check for this?

Using Google Play Services in Android ; is there a way to get the Location from only GPS?

Using Google Play Services 's Location Service , is there a way to specify that we get the Location only from GPS device on the android device?
This should be a handy guide in telling you how to request your location strictly from the GPS. Be sure to read carefully in the Requesting Location Updates section.
Granted, this is not using the Google Play Services Location Service, but I believe the difference between the two is that, by using Google Play, you can skip the step of calling both GPS_PROVIDER and NETWORK_PROVIDER. Additionally, Google Play Services Location Service stores the most recent Location in the GoogleApiClient so you're not completely out of luck when neither of the providers are working.
Edit
Short answer - No
Long answer:
According to Google's source code, they use the same functions I listed earlier. As far as higher accuracy is concerned, that is obtained through the combination of GPS_PROVIDER and NETWORK_PROVIDER data. A workaround could possibly be passing the FusedLocationProviderApi GPS-only locations through the setMockLocation method.

Android: how to get network coordinates witout signining up in google account

I have some android devices remote from me. And I have own app and root remote access on it. The app can give me devices' GPS coordinates via internet. But It works only if device is signed up in google account. Remote devices are not.
So how I can sign up remotely(using android rooted shell, or some app) or get GPS coordinates without signing up?
I'm not sure where you or the other user are getting your data from, but there's no need for Google account to get location.
There's a simple step by step to get it done https://developer.android.com/training/location/receive-location-updates.html and no where it says anything about Google account.
If you want to use the FusedLocationProvider (as per link) the device must have Google Play Services installed on it. That's an app that is automatically installed by Google on all devices that have Google Play Store.
If your devices does not have Google Play Store installed then you must use the LocationManager https://developer.android.com/reference/android/location/LocationManager.html by calling this code:
LocationManager lm =
(LocationManager) context.getSystemServices(Context.LOCATION_SERVICE);
and making the relevat calls on the lm instance to receive location updates.
Both methods need location permissions on your AndroidManifest.xml but none needs the user to have a Google Account.
The Location Services using not only the GPS but also the surrounding WiFi networks and network localisation are services provided by Google, unrelated to GPS global technology.
The network/wifi localisation service REQUIRES a Google Account to work.

Does android get user's location by network need Google Map installed

My problem is the same with
cannot get place from google map using location
I installed a new android ROM and tested locationlistener with network location provider, nothing would return back.
But if I install Google Map from Market, and position myself in Google Map by network, it can locate me, and after that, I can locate myself in my app also. It looks like to install Google Market is a must for network locating.
Correct me if I am wrong. Is that true?
No, Google Maps has nothing to do with your network location.
If you enable (on your device settings) and set (in your code) that provider in your app then you can use it too. LocationManager.NETWORK_PROVIDER is what I'm talking about. Read more on the link below.
http://developer.android.com/reference/android/location/LocationManager.html

Categories

Resources