Example usage for android.location LocationManager GPS_PROVIDER

List of usage examples for android.location LocationManager GPS_PROVIDER

Introduction

In this page you can find the example usage for android.location LocationManager GPS_PROVIDER.

Prototype

String GPS_PROVIDER

To view the source code for android.location LocationManager GPS_PROVIDER.

Click Source Link

Document

Name of the GPS location provider.

Usage

From source file:com.hufeiya.SignIn.activity.QuizActivity.java

private void getLocation() {
    locationManager = (LocationManager) MyApplication.getContext().getSystemService(Context.LOCATION_SERVICE);
    if (ActivityCompat.checkSelfPermission(MyApplication.getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(MyApplication.getContext(),
                    Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        Toast.makeText(QuizActivity.this, "??? ( > c < ) ", Toast.LENGTH_SHORT).show();
        String locationPermissions[] = { Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_COARSE_LOCATION };
        int currentapiVersion = android.os.Build.VERSION.SDK_INT;
        if (currentapiVersion >= 23) {
            requestPermissions(locationPermissions, REQUEST_CODE_FOR_POSITON);
        }//ww  w  .j av a2s .com
        return;
    }
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, this);
}

From source file:com.bangz.smartmute.services.LocationMuteService.java

private boolean addGeofences(List<Geofence> geofences) {

    ConnectionResult connresult = mGoogleApiClient.blockingConnect();
    if (connresult.isSuccess() == false) {
        LogUtils.LOGE(TAG, "GoogleApiClient.blockingConnect failed! message: " + connresult.toString());
        return false;
    }//from   w  ww.  j  av a 2s.co m

    GeofencingRequest gR = new GeofencingRequest.Builder().addGeofences(geofences)
            .setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER | GeofencingRequest.INITIAL_TRIGGER_DWELL
                    | GeofencingRequest.INITIAL_TRIGGER_EXIT)
            .build();
    PendingIntent pi = getGeofencesPendingIntent(this);
    Status rs = LocationServices.GeofencingApi.addGeofences(mGoogleApiClient, gR, pi).await();
    boolean bret = false;
    if (rs.isSuccess()) {

        LogUtils.LOGD(TAG, "Add Geofence successful.");
        PrefUtils.Geofencing(this, true);
        ReceUtils.enableReceiver(this, LocationProviderChangedReceiver.class, false);
        bret = true;

    } else {
        int errcode = rs.getStatusCode();
        bret = false;
        LogUtils.LOGD(TAG, "Add Geofence failed! errorcode = " + errcode + "Message:" + rs.getStatusMessage());

        if (errcode == GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE) {

            LocationManager lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
            if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)
                    || lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {

                LogUtils.LOGD(TAG,
                        "GPS or Network Provider is enabled. " + "Notification User to try add again late?");

            } else {

                ReceUtils.enableReceiver(this, LocationProviderChangedReceiver.class, true);
            }

            NotificationUserFailed();

        }
    }

    mGoogleApiClient.disconnect();

    return bret;
}

From source file:carsharing.starter.automotive.iot.ibm.com.mobilestarterapp.AnalyzeMyDriving.java

private void getAccurateLocation(final GoogleMap googleMap) {
    final FragmentActivity activity = getActivity();
    if (activity == null) {
        Log.e("getAccurateLocation", "do nothing as getActivity()==null");
        if (locationManager != null) {
            requestLocationUpdates(false);
        }/*from w ww.  ja  va  2 s  .c om*/
        return;
    }
    final ConnectivityManager connectivityManager = (ConnectivityManager) activity
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

    final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    final boolean networkConnected = networkInfo != null && networkInfo.isConnected();
    if (gpsEnabled && networkConnected) {
        if (!checkCurrentLocation()) {
            Log.e("Location Data", "Not Working!");
            //                Toast.makeText(getActivity().getApplicationContext(), "Please activate your location settings and restart the application!", Toast.LENGTH_LONG).show();
            getAccurateLocation(mMap);
            return;
        }
        if (mMap != null) {
            float zoom = mMap.getCameraPosition().zoom;
            zoom = Math.max(14, zoom);
            zoom = Math.min(18, zoom);

            mMap.clear();
            final LatLng newLocation = new LatLng(location.getLatitude(), location.getLongitude());
            //                if (!cameraSet) {
            mMap.moveCamera(CameraUpdateFactory.newLatLng(newLocation));
            mMap.animateCamera(CameraUpdateFactory.zoomTo(zoom), 2000, null);
            //                    cameraSet = true;
            //                }
            mMap.addMarker(new MarkerOptions().position(newLocation).title("Your Location")
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.models)));
        }
        final ActionBar supportActionBar = ((AppCompatActivity) activity).getSupportActionBar();
        if (startedDriving) {
            if (!behaviorDemo) {
                // get credentials may be failed
                startedDriving = false;
                completeReservation(reservationId[0], false);
                return;
            }
            speedMessage = "" + Math.round(location.getSpeed() * 60 * 60 / 16.0934) / 100.0 + " MPH";
            supportActionBar.setTitle(speedMessage + " - Data not sent");

            tripCount += 1;
            if (tripCount % 10 == 0) {
                //                renderMapMatchedLocation()
            }
        } else if (deviceClient != null) {
            supportActionBar.setTitle("Press Start Driving when ready.");
        }
        if (behaviorDemo) {
            API.runInAsyncUIThread(new Runnable() {
                @Override
                public void run() {
                    if (deviceClient == null && needCredentials) {
                        createDeviceClient();
                        connectDeviceClient();
                    }
                    if (userUnlocked) {
                        sendLocation(location);
                    }
                }
            }, activity);
        }
    } else {
        if (!gpsEnabled) {
            Toast.makeText(activity.getApplicationContext(), "Please turn on your GPS", Toast.LENGTH_LONG)
                    .show();

            final Intent gpsIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivityForResult(gpsIntent, GPS_INTENT);

            if (!networkConnected) {
                networkIntentNeeded = true;
            }
        } else if (!networkConnected) {
            Toast.makeText(activity.getApplicationContext(), "Please turn on Mobile Data or WIFI",
                    Toast.LENGTH_LONG).show();

            final Intent settingsIntent = new Intent(Settings.ACTION_SETTINGS);
            startActivityForResult(settingsIntent, SETTINGS_INTENT);
        }
    }
}

From source file:com.jesjimher.bicipalma.MesProperesActivity.java

public void onStatusChanged(String provider, int status, Bundle extras) {
    Toast.makeText(getApplicationContext(), "Cambio estado GPS", Toast.LENGTH_SHORT).show();
    if (provider.equals(LocationManager.GPS_PROVIDER)) {
        if (status != LocationProvider.AVAILABLE)
            activarUbicacion();/*  w  ww.  j  a v  a  2 s.  com*/
    }
}

From source file:com.davidmascharka.lips.MainActivity.java

@Override
public void onResume() {
    super.onResume();

    // Set building textview to the building the user has selected
    TextView buildingText = (TextView) findViewById(R.id.text_building);
    buildingText.setText("Building: " + building);

    // Set room size textview to the room size the user has selected
    TextView roomSizeText = (TextView) findViewById(R.id.text_room_size);
    roomSizeText.setText("Room size: " + roomWidth + " x " + roomLength);

    // Set grid options
    GridView grid = (GridView) findViewById(R.id.gridView);
    grid.setGridSize(roomWidth, roomLength);
    grid.setDisplayMap(displayMap);/*from   ww  w. jav  a 2s  .co m*/

    // Register to get sensor updates from all the available sensors
    sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL);
    for (Sensor sensor : sensorList) {
        sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_FASTEST);
    }

    // Enable wifi if it is not
    if (!wifiManager.isWifiEnabled()) {
        Toast.makeText(this, "WiFi not enabled. Enabling...", Toast.LENGTH_SHORT).show();
        wifiManager.setWifiEnabled(true);
    }

    // Request location updates from gps and the network
    //@author Mahesh Gaya added permission if-statment
    if (ActivityCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        Log.i(TAG, "Permissions have NOT been granted. Requesting permissions.");
        requestMyPermissions();
    } else {
        Log.i(TAG, "Permissions have already been granted. Getting location from GPS and Network");
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
    }

    registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
}

From source file:com.crearo.gpslogger.ui.fragments.display.GpsDetailedViewFragment.java

public void displayLocationInfo(Location locationInfo) {
    if (locationInfo == null) {
        return;/*  www .j  a va 2  s .com*/
    }

    showPreferencesAndMessages();

    TextView tvLatitude = (TextView) rootView.findViewById(R.id.detailedview_lat_text);
    TextView tvLongitude = (TextView) rootView.findViewById(R.id.detailedview_lon_text);
    TextView tvDateTime = (TextView) rootView.findViewById(R.id.detailedview_datetime_text);

    TextView tvAltitude = (TextView) rootView.findViewById(R.id.detailedview_altitude_text);

    TextView txtSpeed = (TextView) rootView.findViewById(R.id.detailedview_speed_text);

    TextView txtSatellites = (TextView) rootView.findViewById(R.id.detailedview_satellites_text);
    TextView txtDirection = (TextView) rootView.findViewById(R.id.detailedview_direction_text);
    TextView txtAccuracy = (TextView) rootView.findViewById(R.id.detailedview_accuracy_text);
    TextView txtTravelled = (TextView) rootView.findViewById(R.id.detailedview_travelled_text);
    TextView txtTime = (TextView) rootView.findViewById(R.id.detailedview_duration_text);
    String providerName = locationInfo.getProvider();
    if (providerName.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
        providerName = getString(R.string.providername_gps);
    } else {
        providerName = getString(R.string.providername_celltower);
    }

    tvDateTime.setText(android.text.format.DateFormat.getDateFormat(getActivity())
            .format(new Date(Session.getLatestTimeStamp())) + " - " + providerName);

    NumberFormat nf = NumberFormat.getInstance();

    nf.setMaximumFractionDigits(6);
    tvLatitude.setText(String.valueOf(nf.format(locationInfo.getLatitude())));
    tvLongitude.setText(String.valueOf(nf.format(locationInfo.getLongitude())));

    nf.setMaximumFractionDigits(3);

    if (locationInfo.hasAltitude()) {
        tvAltitude.setText(Strings.getDistanceDisplay(getActivity(), locationInfo.getAltitude(),
                preferenceHelper.shouldDisplayImperialUnits()));
    } else {
        tvAltitude.setText(R.string.not_applicable);
    }

    if (locationInfo.hasSpeed()) {
        txtSpeed.setText(Strings.getSpeedDisplay(getActivity(), locationInfo.getSpeed(),
                preferenceHelper.shouldDisplayImperialUnits()));

    } else {
        txtSpeed.setText(R.string.not_applicable);
    }

    if (locationInfo.hasBearing()) {

        float bearingDegrees = locationInfo.getBearing();
        String direction;

        direction = Strings.getBearingDescription(bearingDegrees, getActivity().getApplicationContext());

        txtDirection.setText(direction + "(" + String.valueOf(Math.round(bearingDegrees))
                + getString(R.string.degree_symbol) + ")");
    } else {
        txtDirection.setText(R.string.not_applicable);
    }

    if (!Session.isUsingGps()) {
        txtSatellites.setText(R.string.not_applicable);
    }

    if (locationInfo.hasAccuracy()) {

        float accuracy = locationInfo.getAccuracy();
        txtAccuracy.setText(getString(R.string.accuracy_within, Strings.getDistanceDisplay(getActivity(),
                accuracy, preferenceHelper.shouldDisplayImperialUnits()), ""));

    } else {
        txtAccuracy.setText(R.string.not_applicable);
    }

    double distanceValue = Session.getTotalTravelled();
    txtTravelled.setText(Strings.getDistanceDisplay(getActivity(), distanceValue,
            preferenceHelper.shouldDisplayImperialUnits()) + " (" + Session.getNumLegs() + " points)");

    long startTime = Session.getStartTimeStamp();
    Date d = new Date(startTime);
    long currentTime = System.currentTimeMillis();

    String duration = Strings.getDescriptiveDurationString((int) (currentTime - startTime) / 1000,
            getActivity());

    DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
    DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getActivity().getApplicationContext());
    txtTime.setText(duration + " (started at " + dateFormat.format(d) + " " + timeFormat.format(d) + ")");

}

From source file:com.mendhak.gpslogger.ui.fragments.display.GpsDetailedViewFragment.java

public void displayLocationInfo(Location locationInfo) {
    if (locationInfo == null) {
        return;/*from  w w w .jav  a2  s .co  m*/
    }

    showPreferencesAndMessages();

    TextView tvLatitude = (TextView) rootView.findViewById(R.id.detailedview_lat_text);
    TextView tvLongitude = (TextView) rootView.findViewById(R.id.detailedview_lon_text);
    TextView tvDateTime = (TextView) rootView.findViewById(R.id.detailedview_datetime_text);

    TextView tvAltitude = (TextView) rootView.findViewById(R.id.detailedview_altitude_text);

    TextView txtSpeed = (TextView) rootView.findViewById(R.id.detailedview_speed_text);

    TextView txtSatellites = (TextView) rootView.findViewById(R.id.detailedview_satellites_text);
    TextView txtDirection = (TextView) rootView.findViewById(R.id.detailedview_direction_text);
    TextView txtAccuracy = (TextView) rootView.findViewById(R.id.detailedview_accuracy_text);
    TextView txtTravelled = (TextView) rootView.findViewById(R.id.detailedview_travelled_text);
    TextView txtTime = (TextView) rootView.findViewById(R.id.detailedview_duration_text);
    String providerName = locationInfo.getProvider();
    if (providerName.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
        providerName = getString(R.string.providername_gps);
    } else {
        providerName = getString(R.string.providername_celltower);
    }

    tvDateTime.setText(android.text.format.DateFormat.getDateFormat(getActivity())
            .format(new Date(Session.getLatestTimeStamp())) + " "
            + new SimpleDateFormat("HH:mm:ss").format(new Date(Session.getLatestTimeStamp())) + " - "
            + providerName);

    NumberFormat nf = NumberFormat.getInstance();

    nf.setMaximumFractionDigits(6);
    tvLatitude.setText(String.valueOf(nf.format(locationInfo.getLatitude())));
    tvLongitude.setText(String.valueOf(nf.format(locationInfo.getLongitude())));

    nf.setMaximumFractionDigits(3);

    if (locationInfo.hasAltitude()) {
        tvAltitude.setText(Strings.getDistanceDisplay(getActivity(), locationInfo.getAltitude(),
                preferenceHelper.shouldDisplayImperialUnits()));
    } else {
        tvAltitude.setText(R.string.not_applicable);
    }

    if (locationInfo.hasSpeed()) {
        txtSpeed.setText(Strings.getSpeedDisplay(getActivity(), locationInfo.getSpeed(),
                preferenceHelper.shouldDisplayImperialUnits()));

    } else {
        txtSpeed.setText(R.string.not_applicable);
    }

    if (locationInfo.hasBearing()) {

        float bearingDegrees = locationInfo.getBearing();
        String direction;

        direction = Strings.getBearingDescription(bearingDegrees, getActivity().getApplicationContext());

        txtDirection.setText(direction + "(" + String.valueOf(Math.round(bearingDegrees))
                + getString(R.string.degree_symbol) + ")");
    } else {
        txtDirection.setText(R.string.not_applicable);
    }

    if (!Session.isUsingGps()) {
        txtSatellites.setText(R.string.not_applicable);
    }

    if (locationInfo.hasAccuracy()) {

        float accuracy = locationInfo.getAccuracy();
        txtAccuracy.setText(getString(R.string.accuracy_within, Strings.getDistanceDisplay(getActivity(),
                accuracy, preferenceHelper.shouldDisplayImperialUnits()), ""));

    } else {
        txtAccuracy.setText(R.string.not_applicable);
    }

    double distanceValue = Session.getTotalTravelled();
    txtTravelled.setText(Strings.getDistanceDisplay(getActivity(), distanceValue,
            preferenceHelper.shouldDisplayImperialUnits()) + " (" + Session.getNumLegs() + " points)");

    long startTime = Session.getStartTimeStamp();
    Date d = new Date(startTime);
    long currentTime = System.currentTimeMillis();

    String duration = Strings.getDescriptiveDurationString((int) (currentTime - startTime) / 1000,
            getActivity());

    DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
    DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getActivity().getApplicationContext());
    txtTime.setText(duration + " (started at " + dateFormat.format(d) + " " + timeFormat.format(d) + ")");

}

From source file:com.landenlabs.all_devtool.GpsFragment.java

@SuppressWarnings("deprecation")
@Override/*from   ww w  .  jav  a 2 s .c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    View rootView = inflater.inflate(R.layout.gps_tab, container, false);
    m_statusIcon = Ui.viewById(rootView, R.id.gpsStatus);
    m_statusIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
        }
    });

    Ui.viewById(rootView, R.id.gps_clear).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            clearList();
        }
    });

    m_list.clear();
    // ---- Get UI components  ----
    for (int idx = 0; idx != s_maxRows; idx++)
        m_list.add(null);
    m_list.set(s_providersRow, new GpsInfo(new GpsItem("Providers")));
    m_list.set(s_lastUpdateRow, new GpsInfo(new GpsItem("Last Update")));
    m_list.set(s_detailRow, new GpsInfo(new GpsItem("Detail History")));

    m_listView = Ui.viewById(rootView, R.id.gpsListView);
    final GpsArrayAdapter adapter = new GpsArrayAdapter(this.getActivity());
    m_listView.setAdapter(adapter);

    // ---- Setup GPS ----
    m_locMgr = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);

    m_gpsTv = Ui.viewById(rootView, R.id.gps);
    if (isGooglePlayServicesAvailable()) {
        m_locationRequest = new LocationRequest();
        m_locationRequest.setInterval(GPS_INTERVAL);
        m_locationRequest.setFastestInterval(GPS_FASTEST_INTERVAL);
        // Priority needs to match permissions.
        //  Use LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY with
        // <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
        //  Use LocationRequest.PRIORITY_HIGH_ACCURACY with
        // <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        m_locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);

        m_googleApiClient = new GoogleApiClient.Builder(this.getActivity()).addApi(LocationServices.API)
                .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();

        m_gpsTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                m_gpsMonitor = !m_gpsMonitor;
                view.setSelected(m_gpsMonitor);
                addMsgToDetailRow(s_colorMsg, m_gpsMonitor ? "Start Monitor" : "Stop Monitor");
                showProviders();
            }
        });

    } else {
        m_gpsTv.setText("Need Google Play Service");
    }

    if (ActivityCompat.checkSelfPermission(getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        m_locMgr.addGpsStatusListener(this);
    }

    /*  http://stackoverflow.com/questions/11398732/how-do-i-receive-the-system-broadcast-when-gps-status-has-changed
    <uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <receiver android:name=".GpsReceiver">
    <intent-filter>
         <action android:name="android.location.GPS_ENABLED_CHANGE" />
         <action android:name="android.location.PROVIDERS_CHANGED" />
    </intent-filter>
    </receiver>
    */
    // GpsReceiver m_gpsReceiver = new GpsReceiver();
    m_intentFilter.addAction(GpsReceiver.GPS_ENABLED_CHANGE_ACTION);
    if (Build.VERSION.SDK_INT >= 19) {
        m_intentFilter.addAction(LocationManager.MODE_CHANGED_ACTION);
    }
    m_intentFilter.addAction(GpsReceiver.GPS_FIX_CHANGE_ACTION);
    m_intentFilter.addAction(LocationManager.PROVIDERS_CHANGED_ACTION);

    showProviders();
    // TODO - get available providers
    getCheckBox(rootView, R.id.gpsFuseCb, FUSED_PROVIDER);
    getCheckBox(rootView, R.id.gpsGPSCb, LocationManager.GPS_PROVIDER);
    getCheckBox(rootView, R.id.gpsNetwkCb, LocationManager.NETWORK_PROVIDER);
    getCheckBox(rootView, R.id.gpsLowPwrCb, LocationManager.PASSIVE_PROVIDER);
    getCheckBox(rootView, R.id.gpsStatusCb, STATUS_CB);

    for (CheckBox cb : m_providersCb.values()) {
        cb.setOnClickListener(this);
    }
    initLastUpdate();

    // Expand All
    for (int idx = 0; idx != s_maxRows; idx++)
        m_listView.expandGroup(idx);

    return rootView;
}

From source file:tcc.iesgo.activity.ClientMapActivity.java

@Override
protected void onResume() {
    super.onResume();
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 120000, 100f, ClientMapActivity.this);
}

From source file:com.nextgis.firereporter.GetFiresService.java

protected void GetUserData(boolean bShowProgress) {
    Location currentLocation = null;
    String sLat = null, sLon = null;

    if (mLocManager != null) {
        currentLocation = mLocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (currentLocation == null) {
            currentLocation = mLocManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }// ww  w . j a va 2 s.  co  m

        if (currentLocation == null) {
            SendError(getString(R.string.noLocation));
            return;
        } else {
            sLat = Double.toString(currentLocation.getLatitude());
            sLon = Double.toString(currentLocation.getLongitude());
        }
    }

    SharedPreferences prefs = getSharedPreferences(MainActivity.PREFERENCES, MODE_PRIVATE | MODE_MULTI_PROCESS);
    String sURL = prefs.getString(SettingsActivity.KEY_PREF_SRV_USER,
            getResources().getString(R.string.stDefaultServer));
    String sLogin = prefs.getString(SettingsActivity.KEY_PREF_SRV_USER_USER, "firereporter");
    String sPass = prefs.getString(SettingsActivity.KEY_PREF_SRV_USER_PASS, "8QdA4");
    int nDayInterval = prefs.getInt(SettingsActivity.KEY_PREF_SEARCH_DAY_INTERVAL + "_int", 5);
    int fetchRows = prefs.getInt(SettingsActivity.KEY_PREF_ROW_COUNT + "_int", 15);
    int searchRadius = prefs.getInt(SettingsActivity.KEY_PREF_FIRE_SEARCH_RADIUS + "_int", 5) * 1000;//meters
    boolean searchByDate = prefs.getBoolean("search_current_date", false);

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    long diff = 86400000L * nDayInterval;//1000 * 60 * 60 * 24 * 5;// 5 days  
    date.setTime(date.getTime() - diff);
    String dt = dateFormat.format(date);

    String sFullURL = sURL + "?function=get_rows_user&user=" + sLogin + "&pass=" + sPass + "&limit=" + fetchRows
            + "&radius=" + searchRadius;//
    if (searchByDate) {
        sFullURL += "&date=" + dt;
    }
    if (sLat.length() > 0 && sLon.length() > 0) {
        sFullURL += "&lat=" + sLat + "&lon=" + sLon;
    }

    //SELECT * FROM (SELECT id, report_date, latitude, longitude, round(ST_Distance_Sphere(ST_PointFromText('POINT(37.506247479468584 55.536129316315055)', 4326), fires.geom)) AS dist FROM fires WHERE ST_Intersects(fires.geom, ST_GeomFromText('POLYGON((32.5062474795 60.5361293163, 42.5062474795 60.5361293163, 42.5062474795 50.5361293163, 32.5062474795 50.5361293163, 32.5062474795 60.5361293163))', 4326) ) AND CAST(report_date as date) >= '2013-09-27')t WHERE dist <= 5000 LIMIT 15
    //String sRemoteData = "http://gis-lab.info/data/zp-gis/soft/fires.php?function=get_rows_nasa&user=fire_usr&pass=J59DY&limit=5";
    new HttpGetter(this, 1, getResources().getString(R.string.stDownLoading), mFillDataHandler, bShowProgress)
            .execute(sFullURL);
}