protected JSONObject doWork() {
        Location location;
        Double latitude = 0.0;
 locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        isGPSEnabled = locationManager
                .isProviderEnabled(LocationManager.GPS_PROVIDER);
        // getting network status
        isNetworkEnabled = locationManager
                .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        }
        else {
            this.canGetLocation = true;
            // First get location from Network Provider
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network");
                if (locationManager != null) {
                    location = locationManager
                            .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        Log.i("Provider", provider + " has been selected.");
                        latitude = location.getLatitude();
                        onLocationChanged(location);
                    }
                }
                // latitude = location.getLatitude();
                // longitude = location.getLongitude();
            }
        }
        JSONObject result = new JSONObject();
           try {
            String msg = "KAsun " + mHelloTo + " - its currently "
                    + latitude.toString();
            result.put("Message", msg);
            Log.d(TAG, msg);
        } catch (JSONException e) {
        }
        return result;
I tried above code to generate Current GPS location through NETWORK .but when i try that i get following error.I used to this code to work as a background service.And Can you Tell me why this error occurs
 12-27 09:34:39.406: I/BackgroundService(14495): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
