D
D
DanyKen2021-08-08 14:05:41
Java
DanyKen, 2021-08-08 14:05:41

My error is java.lang.string com.google.firebase.auth.firebaseuser.getuid()' what should I do?

I get an error, I tried different methods but it didn’t help, I don’t know what to do, I press the “exit” button and I have to get to the main menu but it crashes, there are errors in the photo that I get, I don’t really understand programming, I hope to explain in detail, thanks in advance.

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);
    }

}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question