Answers for "how to get exact latitude longitude fromandroid studio"

0

how to get exact latitude longitude fromandroid studio

@SuppressLint("MissingPermission")
private void getLastLocation(){
    if (checkPermissions()) {
        if (isLocationEnabled()) {
            mFusedLocationClient.getLastLocation().addOnCompleteListener(
                    new OnCompleteListener<Location>() {
                        @Override
                        public void onComplete(@NonNull Task<Location> task) {
                            Location location = task.getResult();
                            if (location == null) {
                                requestNewLocationData();
                            } else {
                                latTextView.setText(location.getLatitude()+"");
                                lonTextView.setText(location.getLongitude()+"");
                            }
                        }
                    }
            );
        } else {
            Toast.makeText(this, "Turn on location", Toast.LENGTH_LONG).show();
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
    } else {
        requestPermissions();
    }
}
Posted by: Guest on May-03-2020

Code answers related to "how to get exact latitude longitude fromandroid studio"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language