Java Code Examples for android.location.LocationManager#getBestProvider()

The following examples show how to use android.location.LocationManager#getBestProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChronometerView.java    From open-quartz with Apache License 2.0 6 votes vote down vote up
public ChronometerView(Context context) {
    this(context, null, 0);

    final StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
            .permitAll().build();
    StrictMode.setThreadPolicy(policy);

    locationManager = (LocationManager) context
            .getSystemService(Context.LOCATION_SERVICE);
    geocoder = new Geocoder(context);

    criteria = new Criteria();
    best = locationManager.getBestProvider(criteria, true);
    location = locationManager.getLastKnownLocation(best);

    providers = locationManager.getProviders(criteria, true);

    for (String provider : providers) {
        locationManager.requestLocationUpdates(provider, 0, 0, this);
        Log.e("TAG", "" + provider);
    }

}
 
Example 2
Source File: RxLocationTool.java    From RxTools-master with Apache License 2.0 6 votes vote down vote up
/**
 * 注册
 * <p>使用完记得调用{@link #unRegisterLocation()}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>}</p>
 * <p>如果{@code minDistance}为0,则通过{@code minTime}来定时更新;</p>
 * <p>{@code minDistance}不为0,则以{@code minDistance}为准;</p>
 * <p>两者都为0,则随时刷新。</p>
 *
 * @param minTime     位置信息更新周期(单位:毫秒)
 * @param minDistance 位置变化最小距离:当位置距离变化超过此值时,将更新位置信息(单位:米)
 * @param listener    位置刷新的回调接口
 * @return {@code true}: 初始化成功<br>{@code false}: 初始化失败
 */
public static boolean registerLocation(Context context, long minTime, long minDistance, OnLocationChangeListener listener) {
    if (listener == null) return false;
    if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
        ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
        return false;
    }
    mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    mListener = listener;
    if (!isLocationEnabled(context)) {
        RxToast.showToast(context, "无法定位,请打开定位服务", 500);
        return false;
    }
    String provider = mLocationManager.getBestProvider(getCriteria(), true);

    Location location = mLocationManager.getLastKnownLocation(provider);
    if (location != null) listener.getLastKnownLocation(location);
    if (myLocationListener == null) myLocationListener = new MyLocationListener();
    mLocationManager.requestLocationUpdates(provider, minTime, minDistance, myLocationListener);
    return true;
}
 
Example 3
Source File: Util.java    From letv with Apache License 2.0 6 votes vote down vote up
public static String getLocation(Context context) {
    if (context == null) {
        return "";
    }
    try {
        LocationManager locationManager = (LocationManager) context.getSystemService(HOME_RECOMMEND_PARAMETERS.LOCATION);
        Criteria criteria = new Criteria();
        criteria.setCostAllowed(false);
        criteria.setAccuracy(2);
        String bestProvider = locationManager.getBestProvider(criteria, true);
        if (bestProvider != null) {
            Location lastKnownLocation = locationManager.getLastKnownLocation(bestProvider);
            if (lastKnownLocation == null) {
                return "";
            }
            double latitude = lastKnownLocation.getLatitude();
            g = latitude + "*" + lastKnownLocation.getLongitude();
            return g;
        }
    } catch (Throwable e) {
        f.b("getLocation", "getLocation>>>", e);
    }
    return "";
}
 
Example 4
Source File: ShowLocationActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	latituteField = (TextView) findViewById(R.id.TextView02);
	longitudeField = (TextView) findViewById(R.id.TextView04);

	// Get the location manager
	locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
	// Define the criteria how to select the locatioin provider -> use
	// default
	Criteria criteria = new Criteria();
	provider = locationManager.getBestProvider(criteria, false);
	Location location = locationManager.getLastKnownLocation(provider);

	// Initialize the location fields
	if (location != null) {
		System.out.println("Provider " + provider + " has been selected.");
		onLocationChanged(location);
	} else {
		latituteField.setText("Location not available");
		longitudeField.setText("Location not available");
	}
}
 
Example 5
Source File: LocationUtils.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
/**
 * 注册
 * <p>使用完记得调用{@link #unregister()}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET" />}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />}</p>
 * <p>如果{@code minDistance}为0,则通过{@code minTime}来定时更新;</p>
 * <p>{@code minDistance}不为0,则以{@code minDistance}为准;</p>
 * <p>两者都为0,则随时刷新。</p>
 *
 * @param minTime     位置信息更新周期(单位:毫秒)
 * @param minDistance 位置变化最小距离:当位置距离变化超过此值时,将更新位置信息(单位:米)
 * @param listener    位置刷新的回调接口
 * @return {@code true}: 初始化成功<br>{@code false}: 初始化失败
 */
@RequiresPermission(ACCESS_FINE_LOCATION)
public static boolean register(long minTime, long minDistance, OnLocationChangeListener listener) {
    if (listener == null) return false;
    mLocationManager = (LocationManager) Utils.getApp().getSystemService(Context.LOCATION_SERVICE);
    if (!mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
            && !mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        Log.d("LocationUtils", "无法定位,请打开定位服务");
        return false;
    }
    mListener = listener;
    String provider = mLocationManager.getBestProvider(getCriteria(), true);
    Location location = mLocationManager.getLastKnownLocation(provider);
    if (location != null) listener.getLastKnownLocation(location);
    if (myLocationListener == null) myLocationListener = new MyLocationListener();
    mLocationManager.requestLocationUpdates(provider, minTime, minDistance, myLocationListener);
    return true;
}
 
Example 6
Source File: GPSTracker.java    From AsteroidOSSync with GNU General Public License v3.0 6 votes vote down vote up
public void updateLocation() {
    try {
        mLocationManager = (LocationManager) mContext
                .getSystemService(LOCATION_SERVICE);

        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_LOW);
        criteria.setSpeedRequired(false);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        String provider = mLocationManager.getBestProvider(criteria, true);
        if(provider != null) {
            mLocationManager.requestSingleUpdate(provider, this, null);
            mCanGetLocation = true;
        }
    }
    catch (SecurityException | NullPointerException e) {
        e.printStackTrace();
    }
}
 
Example 7
Source File: LocationLogic.java    From redalert-android with Apache License 2.0 6 votes vote down vote up
public static Location GetLastKnownLocation(Context context) {
    // Get location manager
    LocationManager locationManager = (LocationManager) context.getSystemService(context.LOCATION_SERVICE);

    // Create location criteria
    Criteria criteria = new Criteria();

    // Set fine accuracy
    criteria.setAccuracy(criteria.ACCURACY_FINE);

    // Get best provider
    String bestProvider = locationManager.getBestProvider(criteria, false);

    // No provider?
    if (bestProvider == null) {
        // Return null
        return null;
    }

    // Return last location
    return locationManager.getLastKnownLocation(bestProvider);
}
 
Example 8
Source File: LocationProvider.java    From open-quartz with Apache License 2.0 6 votes vote down vote up
public LocationProvider(Context context) {
    mLocationManager = (LocationManager) context
            .getSystemService(Context.LOCATION_SERVICE);
    mGeocoder = new Geocoder(context);

    final Criteria criteria = new Criteria();
    mBestProvider = mLocationManager.getBestProvider(criteria,
            true);

    final List<String> providers = mLocationManager.getProviders(
            criteria, true);

    for (String provider : providers) {
        // mLocationManager.requestLocationUpdates(provider, 0, 0, this);
    }
}
 
Example 9
Source File: DeviceLocation.java    From ARCore-Location with MIT License 5 votes vote down vote up
public DeviceLocation() {

        try {
            // Getting LocationManager object
            locationManager = (LocationManager) LocationScene.mContext.getSystemService(Context.LOCATION_SERVICE);
            // Creating an empty criteria object
            Criteria criteria = new Criteria();

            // Getting the name of the provider that meets the criteria
            provider = locationManager.getBestProvider(criteria, false);

            if (provider != null && !provider.equals("")) {

                // Get the location from the given provider
                Location location = locationManager.getLastKnownLocation(provider);
                locationManager.requestLocationUpdates(provider, 1000, 1, this);

                if (location != null)
                    onLocationChanged(location);
                else
                    Toast.makeText(LocationScene.mContext, "Location can't be retrieved", Toast.LENGTH_SHORT).show();

            } else {
                Toast.makeText(LocationScene.mContext, "No Provider Found", Toast.LENGTH_SHORT).show();
            }

        } catch(SecurityException e) {
            Toast.makeText(LocationScene.mContext, "Enable location permissions from settings", Toast.LENGTH_SHORT).show();
        }
    }
 
Example 10
Source File: MainFragment.java    From AndroidSlidingUpPanel-foursquare-map-demo with Apache License 2.0 5 votes vote down vote up
private LatLng getLastKnownLocation(boolean isMoveMarker) {
    LocationManager lm = (LocationManager) TheApp.getAppContext().getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_LOW);
    String provider = lm.getBestProvider(criteria, true);
    if (provider == null) {
        return null;
    }
    Activity activity = getActivity();
    if (activity == null) {
        return null;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (activity.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
                activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            return null;
        }
    }
    Location loc = lm.getLastKnownLocation(provider);
    if (loc != null) {
        LatLng latLng = new LatLng(loc.getLatitude(), loc.getLongitude());
        if (isMoveMarker) {
            moveMarker(latLng);
        }
        return latLng;
    }
    return null;
}
 
Example 11
Source File: AbstractBarterLiFragment.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
public boolean isLocationServiceEnabled() {
    LocationManager lm = (LocationManager) getActivity()
            .getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();

    String provider = lm.getBestProvider(criteria, true);
    return ((provider != null) && !LocationManager.PASSIVE_PROVIDER
            .equals(provider));
}
 
Example 12
Source File: Engine.java    From tilt-game-android with MIT License 5 votes vote down vote up
public void enableLocationSensor(final Context pContext, final ILocationListener pLocationListener, final LocationSensorOptions pLocationSensorOptions) {
	this.mLocationListener = pLocationListener;

	final LocationManager locationManager = (LocationManager) pContext.getSystemService(Context.LOCATION_SERVICE);
	final String locationProvider = locationManager.getBestProvider(pLocationSensorOptions, pLocationSensorOptions.isEnabledOnly());
	// TODO locationProvider can be null, in that case return false. Successful case should return true.
	locationManager.requestLocationUpdates(locationProvider, pLocationSensorOptions.getMinimumTriggerTime(), pLocationSensorOptions.getMinimumTriggerDistance(), this);

	this.onLocationChanged(locationManager.getLastKnownLocation(locationProvider));
}
 
Example 13
Source File: LocationHelper.java    From RxAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
/**
 * Returns best location using LocationManager.getBestProvider()
 *
 * @param context
 * @return Location|null
 */
public static Location getLocation(Context context) {

    Log.d("LocationHelper", "getLocation()");


    // fetch last known location and update it
    try {
        LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        String strLocationProvider = lm.getBestProvider(criteria, true);


        Log.d("LocationHelper", "strLocationProvider=" + strLocationProvider);

        Location location = getLastKnownLocation(context);//lm.getLastKnownLocation(strLocationProvider);
        if (location != null) {
            return location;
        }
        return null;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 14
Source File: LocationHelper.java    From MVPAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
/**
 * Returns best location using LocationManager.getBestProvider()
 *
 * @param context
 * @return Location|null
 */
public static Location getLocation(Context context) {

    Log.d("LocationHelper", "getLocation()");


    // fetch last known location and update it
    try {
        LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        String strLocationProvider = lm.getBestProvider(criteria, true);


        Log.d("LocationHelper", "strLocationProvider=" + strLocationProvider);

        Location location = getLastKnownLocation(context);//lm.getLastKnownLocation(strLocationProvider);
        if (location != null) {
            return location;
        }
        return null;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 15
Source File: LocationInfo.java    From batteryhub with Apache License 2.0 5 votes vote down vote up
public static String getBestProvider(Context context) {
    LocationManager manager = (LocationManager)
            context.getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();

    criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    criteria.setPowerRequirement(Criteria.POWER_LOW);

    return manager.getBestProvider(criteria, true);
}
 
Example 16
Source File: HandlerService.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
/**
 * Insert GPS location data to the intent.
 * 
 * @param intent
 *          the intent to modify
 */
private void insertLocationData(Intent intent) {
  LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  Location location = null;

  String bestProvider = locationManager.getBestProvider(new Criteria(), true);
  String locationData;
  try {
    location = locationManager.getLastKnownLocation(bestProvider);
    OmniArea newLocation = new OmniArea(null, location.getLatitude(), location.getLongitude(),
        location.getAccuracy());
    locationData = newLocation.toString();
  } catch (Exception e) {
    locationData = "";

    if (location == null) {
      /*
       * Use the normal logging since this case happens quite often, and we don't want to clutter
       * the logs.
       */
      Log.i(TAG, getString(R.string.location_not_available));
    } else if (bestProvider == null) {
      Logger.w(TAG, getString(R.string.location_no_provider));
    } else {
      Logger.w(TAG, getString(R.string.location_unknown_error), e);
    }
  }

  intent.putExtra(Event.ATTRIBUTE_LOCATION, locationData);
}
 
Example 17
Source File: DeviceLocation.java    From ARCore-Location with MIT License 5 votes vote down vote up
public DeviceLocation() {

        try {
            // Getting LocationManager object
            locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
            // Creating an empty criteria object
            Criteria criteria = new Criteria();

            // Getting the name of the provider that meets the criteria
            provider = locationManager.getBestProvider(criteria, false);

            if (provider != null && !provider.equals("")) {

                // Get the location from the given provider
                Location location = locationManager.getLastKnownLocation(provider);
                locationManager.requestLocationUpdates(provider, 1000, 1, this);

                if (location != null)
                    onLocationChanged(location);
                else
                    Toast.makeText(activity, "Location can't be retrieved", Toast.LENGTH_SHORT).show();

            } else {
                Toast.makeText(activity, "No Provider Found", Toast.LENGTH_SHORT).show();
            }

        } catch (SecurityException e) {
            Toast.makeText(activity, "Enable location permissions from settings", Toast.LENGTH_SHORT).show();
        }
    }
 
Example 18
Source File: BetterWeatherExtension.java    From BetterWeather with Apache License 2.0 4 votes vote down vote up
/**
 * Starts the update process, will verify the reason before continuing
 *
 * @param reason Update reason, provided by DashClock or this app
 */
@Override
protected void onUpdateData(int reason) {

    LOGD(TAG, "Update reason: " + getReasonText(reason));

    // Whenever updating, set sLang to Yahoo's format(en-US, not en_US)
    // If sLang is set in elsewhere, and user changes phone's locale
    // without entering BW setting menu, then Yahoo's place name in widget
    // may be in wrong locale.
    Locale current = getResources().getConfiguration().locale;
    YahooPlacesAPIClient.sLang = current.getLanguage() + "-" + current.getCountry();

    if (reason != UPDATE_REASON_USER_REQUESTED &&
            reason != UPDATE_REASON_SETTINGS_CHANGED &&
            reason != UPDATE_REASON_INITIAL &&
            reason != UPDATE_REASON_INTERVAL_TOO_BIG) {
        LOGD(TAG, "Skipping update");
        if ((System.currentTimeMillis() - lastUpdateTime > (sRefreshInterval * 1000 * 60)) && sRefreshInterval > 0)
            onUpdateData(UPDATE_REASON_INTERVAL_TOO_BIG);

        return;
    }

    LOGD(TAG, "Updating data");

    if (sPebbleEnable) {
        LOGD(TAG, "Registered Pebble Data Receiver");
        Pebble.registerPebbleDataReceived(getApplicationContext());
    }

    getCurrentPreferences();

    NetworkInfo ni = ((ConnectivityManager) getSystemService(
            Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
    if (ni == null || !ni.isConnected()) {
        LOGD(TAG, "No internet connection detected, scheduling refresh in 5 minutes");
        scheduleRefresh(5);
        return;
    }

    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    String provider;
    if (sUseOnlyNetworkLocation)
        provider = LocationManager.NETWORK_PROVIDER;
    else
        provider = lm.getBestProvider(sLocationCriteria, true);

    if (TextUtils.isEmpty(provider)) {
        LOGE(TAG, "No available location providers matching criteria, maybe permission is disabled.");
        provider = null;
    }

    requestLocationUpdate(lm, provider);
}
 
Example 19
Source File: DalvikPositionService.java    From attach with GNU General Public License v3.0 4 votes vote down vote up
private void initialize() {    
        
        Object systemService = activityContext.getSystemService(Activity.LOCATION_SERVICE);
        locationManager = (LocationManager) systemService;

        List<String> locationProviders = locationManager.getAllProviders();
        if (debug) {
            Log.v(TAG, String.format("Available location providers on this device: %s.", locationProviders.toString()));
        }
        
        locationProvider = locationManager.getBestProvider(getLocationProvider(), false);
        if (debug) {
            Log.v(TAG, String.format("Picked %s as best location provider.", locationProvider));
        }
        
        boolean locationProviderEnabled = locationManager.isProviderEnabled(locationProvider);
        if (!locationProviderEnabled) {
            if (debug) {
                Log.v(TAG, String.format("Location provider %s is not enabled, starting intent to ask user to activate the location provider.", locationProvider));
            }
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            activityContext.startActivity(intent);
        }

        Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
        if (lastKnownLocation != null) {
            if (debug) {
                Log.v(TAG, String.format("Last known location for provider %s: %f / %f / %f",
                        locationProvider, lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), lastKnownLocation.getAltitude()));
            }
            updatePosition(lastKnownLocation);
        }

/*
        final Intent serviceIntent = new Intent(activityContext, AndroidPositionBackgroundService.class);
        final IntentFilter intentFilter = new IntentFilter(AndroidPositionBackgroundService.class.getName());
        
        Services.get(LifecycleService.class).ifPresent(l -> {
            l.addListener(LifecycleEvent.PAUSE, () -> {
                quitLooperTask();
                // if the PositionService is still running and backgroundModeEnabled 
                // then start background service when the app goes to background
                if (running && parameters.isBackgroundModeEnabled()) {
                    activityContext.registerReceiver(broadcastReceiver, intentFilter);
                    activityContext.startService(serviceIntent);
                }
            });
            l.addListener(LifecycleEvent.RESUME, () -> {
                // if backgroundModeEnabled then stop the background service when
                // the app goes to foreground and resume PositionService
                if (parameters.isBackgroundModeEnabled()) {
                    try {
                        activityContext.unregisterReceiver(broadcastReceiver);
                    } catch (IllegalArgumentException e) {}
                    activityContext.stopService(serviceIntent);
                }
                createLooperTask();
            });
        });
*/
        createLooperTask();
    }
 
Example 20
Source File: MainActivity.java    From nearbydemo with Eclipse Public License 1.0 4 votes vote down vote up
public void getLocation(Context context) {
	LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
	// 设置Criteria的信息
	Criteria criteria = new Criteria();
	// 经度要求
	criteria.setAccuracy(Criteria.ACCURACY_FINE);
	criteria.setAltitudeRequired(false);
	criteria.setBearingRequired(false);
	criteria.setCostAllowed(false);
	criteria.setPowerRequirement(Criteria.POWER_LOW);
	// 根据设置的Criteria对象,获取最符合此标准的provider对象
	// 取得效果做好的criteria
	String currentProvider = locationManager.getBestProvider(criteria, true);
	Log.d(TAG, "currentProvider: " + currentProvider);
	// 根据当前provider对象获取最后一次位置信息
	Location currentLocation = locationManager.getLastKnownLocation(currentProvider);
	if (currentLocation == null) {
		locationManager.requestLocationUpdates(currentProvider, 0, 0, new getGpsLocationListner());
	}
	// 直到获得最后一次位置信息为止,如果未获得最后一次位置信息,则显示默认经纬度
	// 每隔10秒获取一次位置信息
	while (true) {
		currentLocation = locationManager.getLastKnownLocation(currentProvider);
		if (currentLocation != null) {
			Log.d(TAG, "Latitude: " + currentLocation.getLatitude());
			Log.d(TAG, "location: " + currentLocation.getLongitude());
			Map<String, String> map = new HashMap<String, String>();
			map.put("latitude", String.valueOf(currentLocation.getLatitude()));
			map.put("longitude", String.valueOf(currentLocation.getLongitude()));
			map.put("user_id", PhoneUtil.getImei(MainActivity.this));
			requestServer(map);
			break;
		} else {
			Log.d(TAG, "Latitude: " + 0);
			Log.d(TAG, "location: " + 0);
		}
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			Log.e(TAG, e.getMessage());
		}
	}
}