Getting user's current location
The last know location could be null. So you need a further check for this, then ask for a quick update:

   if(location == null){
            String provider = locationManager.getBestProvider(criteria, true);
            if (provider != null){
                locationManager.requestLocationUpdates(provider, 0, 0, singeUpdateListener, context.getMainLooper()); 
            }else {
                Log.e("TAG", No location set");             
            }
    }


class variable:

protected LocationListener singeUpdateListener = new LocationListener() {
        public void onLocationChanged(Location location) {
            String lati = Double.toString(location.getLatitude());
            String longi = Double.toString(location.getLongitude());
            locationManager.removeUpdates(singeUpdateListener);
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {}
        public void onProviderEnabled(String provider) {}
        public void onProviderDisabled(String provider) {}
      };