Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- locationClient = LocationServices.getFusedLocationProviderClient(this);
- googleApiClient = new GoogleApiClient.Builder(this)
- .addApi(LocationServices.API)
- .addConnectionCallbacks(this)
- .build();
- @Override
- public void onConnected(@Nullable Bundle bundle) {
- updateLocation();
- }
- @Override
- public void onConnectionSuspended(int i) {
- googleApiClient.connect();
- }
- @SuppressWarnings({"MissingPermission"})
- @OnClick(R.id.searchRestaurantsFab)
- public void updateLocation() {
- locationClient.getLastLocation().addOnSuccessListener(this, new OnSuccessListener<Location>() {
- @Override
- public void onSuccess(Location location) {
- if (location == null) {
- Toast.makeText(MapsActivity.this, "Включите GPS", Toast.LENGTH_SHORT).show();
- } else if (mapIsReady) {
- mapsFragment.showMyLocation(location);
- updateRestaurants(location);
- }
- }
- });
- }
Add Comment
Please, Sign In to add comment