How Can I Replace Fusedlocationapi With Fusedlocationproviderclient?
I want to find current location on connected. I am currently using FusedLocationApi which is deprecated. i have to use requestLocationUpdate method but i am getting some syntax err
Solution 1:
Your start is like you need.
FusedLocationProviderClient fusedLocationProviderClient; //Global variable
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this); //initiate in onCreate
For getting location from another app as googlemaps you can use mFusedLocationClient.getLastLocation()
it have listeners, addOnSuccessListener
gives to you location, addOnCompleteListener
and task.getResult() == null
means that you need to do your own request like mFusedLocationClient.requestLocationUpdates(getLocationRequest(), mLocationCallback, null);
and you need to remove your listener for example in onPause like mFusedLocationClient.removeLocationUpdates(mLocationCallback)
you can look this examples https://github.com/googlesamples/android-play-location and https://developer.android.com/training/location/receive-location-updates?hl=es
Post a Comment for "How Can I Replace Fusedlocationapi With Fusedlocationproviderclient?"