本文整理了Java中com.google.android.gms.location.FusedLocationProviderClient
类的一些代码示例,展示了FusedLocationProviderClient
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FusedLocationProviderClient
类的具体详情如下:
包路径:com.google.android.gms.location.FusedLocationProviderClient
类名称:FusedLocationProviderClient
暂无
代码示例来源:origin: commonsguy/cw-omnibus
@SuppressLint("MissingPermission")
private void findLocation() {
FusedLocationProviderClient client=
LocationServices.getFusedLocationProviderClient(this);
client.getLastLocation()
.addOnCompleteListener(this, this::useResult)
.addOnFailureListener(this, this::copeWithFailure);
}
代码示例来源:origin: commonsguy/cw-omnibus
@SuppressLint("MissingPermission")
private void findLocation() {
request=buildLocationRequest();
client.requestLocationUpdates(request, cb, Looper.getMainLooper())
.addOnFailureListener(this, e -> {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
Log.e(getClass().getSimpleName(), "Exception getting location", e);
});
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
protected void onStop() {
client.removeLocationUpdates(cb);
request=null;
super.onStop();
}
代码示例来源:origin: TeamWalrus/Walrus
fusedLocationProviderClient.getLastLocation().addOnSuccessListener(
new OnSuccessListener<Location>() {
@Override
fusedLocationProviderClient.requestLocationUpdates(locationRequest,
new LocationCallback() {
@Override
代码示例来源:origin: googlemaps/android-samples
Task<Location> locationResult = mFusedLocationProviderClient.getLastLocation();
locationResult.addOnCompleteListener(this, new OnCompleteListener<Location>() {
@Override
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
private void requestLocationUpdates() {
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
== PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION)
== PERMISSION_GRANTED) {
FusedLocationProviderClient fusedLocationClient
= LocationServices.getFusedLocationProviderClient(this);
fusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
}
}
代码示例来源:origin: swentel/indigenous-android
/**
* Stop location updates.
*/
public void stopLocationUpdates() {
mFusedLocationClient.removeLocationUpdates(mLocationCallback);
}
代码示例来源:origin: mohak1712/UberUX
@RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION)
private void onLocationPermissionGranted() {
if (!checkPermission()) return;
mMap.getUiSettings().setMyLocationButtonEnabled(false);
mMap.setMyLocationEnabled(true);
mFusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if (location != null) {
userLocation = location;
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(userLocation.getLatitude(), userLocation.getLongitude()))
.zoom(17)
.build();
addOverlay(new LatLng(userLocation.getLatitude(), userLocation.getLongitude()));
mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
} else {
userLocation = null;
}
}
});
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
private void requestLocationUpdates() {
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
== PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION)
== PERMISSION_GRANTED) {
FusedLocationProviderClient fusedLocationClient
= LocationServices.getFusedLocationProviderClient(this);
fusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
}
}
代码示例来源:origin: aliumujib/Nibo
@Override
public void onPause() {
super.onPause();
mFusedLocationClient.removeLocationUpdates(mLocationCallback);
}
代码示例来源:origin: ruuvi/com.ruuvi.station
private void updateLocation() {
if (ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
mFusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
tagLocation = location;
}
});
}
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
private void requestLocationUpdates() {
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
== PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION)
== PERMISSION_GRANTED) {
FusedLocationProviderClient fusedLocationClient
= LocationServices.getFusedLocationProviderClient(this);
fusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
}
}
代码示例来源:origin: kingsammalik/SamLocationAndGeocoding
private void stopLocationUpdates() {
LocationServices.getFusedLocationProviderClient(context).removeLocationUpdates(
this);
Log.d("LocationRequestService", "Location update stopped .......................");
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
private void getLastLocation() {
FusedLocationProviderClient fusedLocationClient;
fusedLocationClient =
LocationServices.getFusedLocationProviderClient(this);
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
== PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION)
== PERMISSION_GRANTED) {
fusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
updateTextView(location);
}
});
}
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
private void requestLocationUpdates() {
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
== PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION)
== PERMISSION_GRANTED) {
FusedLocationProviderClient fusedLocationClient
= LocationServices.getFusedLocationProviderClient(this);
fusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
}
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
@Override
protected void onStop() {
super.onStop();
FusedLocationProviderClient fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
fusedLocationClient.removeLocationUpdates(mLocationCallback);
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
private void getLastLocation() {
FusedLocationProviderClient fusedLocationClient;
fusedLocationClient =
LocationServices.getFusedLocationProviderClient(this);
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
== PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION)
== PERMISSION_GRANTED) {
fusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
updateTextView(location);
}
});
}
}
代码示例来源:origin: kingsammalik/SamLocationAndGeocoding
public void startLocationUpdates() {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
LocationServices.getFusedLocationProviderClient(context).requestLocationUpdates(
mLocationRequest,this, null);
Log.d("LocationRequestService", "Location update started ..............: ");
}
代码示例来源:origin: Attriumph/Place-Search-Service
private void stopLocationUpdates() {
if (!mRequestingLocationUpdates) {
Log.d(TAG, "stopLocationUpdates: updates never requested, no-op.");
return;
}
mFusedLocationClient.removeLocationUpdates(mLocationCallback)
.addOnCompleteListener((Activity) context, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
mRequestingLocationUpdates = false;
}
});
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
private void getLastLocation() {
FusedLocationProviderClient fusedLocationClient;
fusedLocationClient =
LocationServices.getFusedLocationProviderClient(this);
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
== PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION)
== PERMISSION_GRANTED) {
fusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
updateTextView(location);
}
});
}
}
内容来源于网络,如有侵权,请联系作者删除!