Android play services 6.5: LocationClient is missing
The LocationClient class has been replaced with the new FusedLocationProviderApi and the GeofencingApi, both of which use the common GoogleApiClient connection technique to connect to Google Play Services. Once you are connected, you can call methods such as requestLocationUpdates():
LocationRequest locationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
PendingResult<Status> result = LocationServices.FusedLocationApi
.requestLocationUpdates(
googleApiClient, // your connected GoogleApiClient
locationRequest, // a request to receive a new location
locationListener); // the listener which will receive updated locations
// Callback is asynchronous. Use await() on a background thread or listen for
// the ResultCallback
result.setResultCallback(new ResultCallback<Status>() {
void onResult(Status status) {
if (status.isSuccess()) {
// Successfully registered
} else if (status.hasResolution()) {
// Google provides a way to fix the issue
status.startResolutionForResult(
activity, // your current activity used to receive the result
RESULT_CODE); // the result code you'll look for in your
// onActivityResult method to retry registering
} else {
// No recovery. Weep softly or inform the user.
Log.e(TAG, "Registering failed: " + status.getStatusMessage());
}
}
});
LocationClient class not found on google play services rev 22
Building on what @CommnsWare said, here are steps to migrate to Fused api.
Step 1: Get an instance of GoogleApiClient
instead of LocationClient
.
The ConnectionCallback
(mConnectionCallbacks, mOnConnectionFailedListener in example below) needs slight modification but that should be trivial.
googleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mOnConnectionFailedListener)
.build();
Step 2: Update connect and disconnect calls.
Replace the locationClient.connect()
with googleApiClient.connect()
and locationClient.disconnect()
with googleApiClient.disconnect()
.
Step 3: Use LocationServices.FusedLocationApi to send your requests.
e.g.
LocationServices.FusedLocationApi.getLastLocation(googleApiClient)
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, mLocationListener);
Hope this helps!
com.google.android.gms classes not found after update of play-services to 6.5.87
ActivityRecognitionClient
was deprecated, and they may have gotten rid of deprecated methods. Either use an earlier version of the artifact, or switch to ActivityRecognition
, which I think is the replacement.
Emulator manual location doesn't work with Google Play Services
I have a suggestion, Try to use Genymotions for testing maps/places app.
it is faster than emulator and you can build and check maps application.
www.genymotion.com/
import com.google.android.gms.location.LocationClient cannot be resolved
Update: The docs seem to be updated now.
I had the same problem about a week ago the problem is because the GooglePlayServices
library is updated and also the LocationClient
was deprecated as well (but the docs were not updated). You must have updated the GooglePlayServices
library and then this error occurred.
So instead of using the old LocationClient
you need to use com.google.android.gms.common.api.GoogleApiClient
and com.google.android.gms.location.LocationRequest
.
See the docs for GoogleApiClient and LocationRequest
Google Play Services location and geofencing APIs not working properly on Genymotion
I had the issue regarding geolocation a few days ago and contacted Genymotion about it. They said they do not currently support Geolocation features but may consider implementing them in the future.
I don't know the answer to your first question as I haven't had this problem.
Related Topics
Drawable-Hdpi, Drawable-Mdpi, Drawable-Ldpi Android
Androidruntime: Fatal Exception: Androidmapsapi-Zoomtablemanager
How to Display a Route Between Two Geocoords in Google Maps
Pass Arraylist<? Implements Parcelable> to Activity
How to Start Power Manager of All Android Manufactures to Enable Background and Push Notification
Android View Not Attached to Window Manager
Spannablestringbuilder to Create String with Multiple Fonts/Text Sizes etc Example
Does the Android Art Runtime Have the Same Method Limit Limitations as Dalvik
Get Thumbnail Uri/Path of the Image Stored in Sd Card + Android
Share Image and Text Through Whatsapp or Facebook
How Does Evaluatejavascript Work
Cannot Catch Toolbar Home Button Click Event
Connecting to Wifi Using Adb Shell
How to Use Android Progressbar in Determinate Mode
How to Check an Android Device Is Hdpi Screen or Mdpi Screen
How to Create Tests in Android Studio