Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void getDeviceLocation() {
- FusedLocationProviderClient mFusedLocationProvirderClient;
- mFusedLocationProvirderClient = LocationServices.getFusedLocationProviderClient(this);
- try {
- Task location = mFusedLocationProvirderClient.getLastLocation();
- location.addOnCompleteListener(new OnCompleteListener() {
- @Override
- public void onComplete(@NonNull Task task) {
- if (task.isSuccessful()) {
- Location currentLocation = (Location) task.getResult();
- moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),
- 15f);
- }else {
- Toast.makeText(MapsActivity.this, "can not find your location", Toast.LENGTH_SHORT).show();
- }
- }
- });
- }
- } catch (Exception e) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement