Hello. There is an application with geolocation. It was checked on several devices, everything works, the location is determined quickly, on devices without a gps module it also finds a location by agps. The problem is that some users zealously complain that the application never connects to gps, and the whole essence of the application is revealed only after the GPS connection is established. Also, too many deletions of the application after installation, I think for the same reason. Below is the code responsible for the GPS connection, maybe I overlooked something in it? Tell me please.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); } @Override protected void onResume() { super.onResume(); ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAltitudeRequired(false); criteria.setBearingRequired(true); criteria.setCostAllowed(false); String provider = mLocationManager.getBestProvider(criteria, true); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; } mLocation = mLocationManager.getLastKnownLocation(provider); mLocationListener = new MyLocationListener(); mLocationManager.requestLocationUpdates(provider, 100, 0, mLocationListener); showCurrentLocation(mLocation); } public void showCurrentLocation(Location location) { if (location != null) { currentLat = location.getLatitude(); currentLon = location.getLongitude(); } } public class MyLocationListener implements LocationListener { public void onLocationChanged(Location location) { myLat = location.getLatitude(); myLon = location.getLongitude(); } public void onStatusChanged(String s, int i, Bundle b) { } public void onProviderDisabled(String s) { } public void onProviderEnabled(String s) { }