Unable to retrieve location using 'LocationManager.NETWORK_PROVIDER' even when WiFi is enabled in device running android M
I'm trying to retrieve location using LocationManager following this tutorial. I'm running the code on an android device running Marshmallow and I have checked the permission and running below code once the permission is granted. Here's my code: public Location getLocation() { try { locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); // getting GPS status isGPSEnabled = locationManager .isProviderEnabled(LocationManager.GPS_PROVIDER); // getting network status isNetworkEnabled = locationManager .isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (!isGPSEnabled &&