@DanyKen

У меня ошибка выходит java.lang.string com.google.firebase.auth.firebaseuser.getuid()' что делать?

У меня ошибка выходит, я пробовал разные способы но не помогло я не знаю что делать, нажимаю кнопку "выход" и должен на главный меню попасть но вылетает, на фото есть ошибки который у меня выходит, я особо не понимаю программирование надеюсь подробный объясните, заранее спасибо.

610fba1ca59bd834207474.jpeg
public class MapDriverActivity extends FragmentActivity implements OnMapReadyCallback,
        GoogleApiClient.ConnectionCallbacks,
                GoogleApiClient.OnConnectionFailedListener,
                        com.google.android.gms.location.LocationListener {
    private GoogleMap mMap;
        GoogleApiClient googleApiClient;
            Location lastLocation;
                LocationRequest locationRequest;
    private Button LogoutDriverButton, SettingsDriverButton;
        private FirebaseAuth mAuth;
            private String currentUser;
                private Boolean currentLogoutDriverStatus;
    @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                        setContentView(R.layout.activity_map_driver);
        mAuth = FirebaseAuth.getInstance();
                currentUser = mAuth.getCurrentUser();
        LogoutDriverButton = (Button)findViewById(R.id.driver_loguot_button);
                SettingsDriverButton = (Button)findViewById(R.id.driver_setting_button);
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                        .findFragmentById(R.id.map);
                                mapFragment.getMapAsync(this);
        LogoutDriverButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                                public void onClick(View v) {
                                                currentLogoutDriverStatus = true;
                                                                mAuth.signOut();
                LogoutDriver();
                                DisconnectDriver();
                                            }
                                                    });
    }
    private void LogoutDriver() {
            Intent welcomeIntent = new Intent(MapDriverActivity.this, WcomeActivity2.class);
                    startActivity(welcomeIntent);
                            finish();
                                }

    @Override
        public void onMapReady(GoogleMap googleMap) {
                mMap = googleMap;
        buildGoogleApiClient();
                if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                            return;
                                    }
                                            mMap.setMyLocationEnabled(true);
                                                }
    @Override
        public void onConnected(@Nullable Bundle bundle) {
                locationRequest = new LocationRequest();
                        locationRequest.setInterval(1000);
                                locationRequest.setFastestInterval(1000);
                                        locationRequest.setPriority(locationRequest.PRIORITY_HIGH_ACCURACY);
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                    return;
                            }
                                    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
                                        }
    @Override
        public void onConnectionSuspended(int i) {
    }
    @Override
        public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    }
    @Override
        public void onLocationChanged( Location location) {
       lastLocation = location;
       LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude());
              mMap.moveCamera(CameraUpdateFactory.newLatLng(latlng));
                     mMap.animateCamera(CameraUpdateFactory.zoomTo(12));
       String userID = FirebaseAuth.getInstance().getCurrentUser().getUid();
               DatabaseReference DriverAvalablityRef = FirebaseDatabase.getInstance().getReference().child("Driver Available");
        GeoFire geoFire = new GeoFire(DriverAvalablityRef);
                geoFire.setLocation(userID, new GeoLocation(location.getLatitude(), location.getLongitude()));
                    }
    protected synchronized void buildGoogleApiClient()
        {
                googleApiClient = new GoogleApiClient.Builder(this)
                                .addConnectionCallbacks(this)
                                                .addOnConnectionFailedListener(this)
                                                                .addApi(LocationServices.API)
                                                                                .build();

        googleApiClient.connect();
            }
    @Override
        protected void onStop() {
                super.onStop();
        if (!currentLogoutDriverStatus) {
                    DisconnectDriver();
                            }

    }

    private void DisconnectDriver() {
            String userID = FirebaseAuth.getInstance().getCurrentUser().getUid();
                    DatabaseReference DriverAvalablityRef = FirebaseDatabase.getInstance().getReference().child("Driver Available");

        GeoFire geoFire = new GeoFire(DriverAvalablityRef);
                geoFire.removeLocation(userID);
    }

}
  • Вопрос задан
  • 142 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы