Refine search
setContentView(R.layout.activity_main); buildGoogleApiClient(); mGoogleApiClient.connect(); Toast.makeText(this,"onConnected",Toast.LENGTH_SHORT).show(); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(10); mLocationRequest.setFastestInterval(10); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); public void onLocationChanged(Location location) { Log.d("locationtesting", "accuracy: " + location.getAccuracy() + " lat: " + location.getLatitude() + " lon: " + location.getLongitude());
locationRequest = new LocationRequest(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(UPDATE_INTERVAL); locationRequest.setFastestInterval(FASTEST_INTERVAL);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(30 * 1000); locationRequest.setFastestInterval(5 * 1000); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest); final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: status.startResolutionForResult( getActivity(), 1000); } catch (IntentSender.SendIntentException e) {
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(1000); // Update location every second
mLocationClient.removeLocationUpdates(this); if (locationmanager != null) locationmanager.removeUpdates(LocUpByLocMgr); } catch (Exception e) { e.printStackTrace(); mLocationClient.connect(); mLocationRequest = LocationRequest.create(); mLocationRequest.setInterval(interval); mLocationRequest .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setFastestInterval(interval); .getSystemService(Context.LOCATION_SERVICE); Criteria cr = new Criteria(); String provider = locationmanager.getBestProvider(cr, true); locationmanager.requestLocationUpdates(provider, interval, 0, LocUpByLocMgr);
mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); try { gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); } catch (Exception ex) { ex.printStackTrace();
updateValuesFromBundle(savedInstanceState); super.onStart(); if (!manager.isProviderEnabled((LocationManager.GPS_PROVIDER))) { buildGoogleApiClient(); mGoogleApiClient.connect(); mMap.setMyLocationEnabled(true); lat = location.getLatitude(); lng = location.getLongitude(); .addApi(LocationServices.API) .build(); createLocationRequest(); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
checkLocationPermission(); if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) showGPSDisabledAlertToUser(); buildGoogleApiClient(); mGoogleMap.setMyLocationEnabled(true); public void onConnected(Bundle bundle) mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(1000); mLocationRequest.setFastestInterval(1000); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(latLng); if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) showGPSDisabledAlertToUser(); if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) showGPSDisabledAlertToUser();
mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(INTERVAL); mLocationRequest.setFastestInterval(FASTEST_INTERVAL); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); boolean gps_enabled; if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { gps_enabled = false; Log.d(TAG, "UI update initiated ............."); if (null != mCurrentLocation) { String lat = String.valueOf(mCurrentLocation.getLatitude()); String lng = String.valueOf(mCurrentLocation.getLongitude()); tvLocation.setText("At Time: " + mLastUpdateTime + "\n" + "Latitude: " + lat + "\n" + "Longitude: " + lng + "\n" + "Accuracy: " + mCurrentLocation.getAccuracy() + "\n" + "Provider: " + mCurrentLocation.getProvider()); } else {
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER) || !manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){ AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle("Location is disabled") if (resultCode == RESULT_OK && requestCode == 100) { Toast.makeText(this, "location enabled", Toast.LENGTH_LONG).show(); if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER) || manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { Toast.makeText(this,"onConnected", Toast.LENGTH_SHORT).show(); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(10); mLocationRequest.setFastestInterval(10); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setSmallestDisplacement(0.1F); public void onLocationChanged(Location location) { Log.d("locationtesting", "lat: " + location.getLatitude() + " lon: " + location.getLongitude());
LocationManager locationManager = (LocationManager) this.mContext.getSystemService(Context.LOCATION_SERVICE); isLocationAvailable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) && locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (mCurrentLocation == null) { mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); Log.d(TAG, "onLocationChanged = " + location.getLatitude()); mCurrentLocation = location; mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(60 * 1000); mLocationRequest.setFastestInterval(60 * 1000); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
.isProviderEnabled(LocationManager.GPS_PROVIDER); .isProviderEnabled(LocationManager.NETWORK_PROVIDER); mLocationrequest = new LocationRequest(); mLocationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(5000);
public void onConnected(Bundle bundle) if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) locationRequest = new LocationRequest(); locationRequest.setInterval(UPDATE_POS_AFTER_MILLIS); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(UPDATE_INTERVAL); locationRequest.setFastestInterval(FASTEST_INTERVAL); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); return location;
if (checkPlayServices()) { buildGoogleApiClient(); createLocationRequest(); double latitude = mLastLocation.getLatitude(); double longitude = mLastLocation.getLongitude(); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(UPDATE_INTERVAL); mLocationRequest.setFastestInterval(FATEST_INTERVAL); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); createLocationRequest(); TextView mTextView = (TextView)findViewById(R.id.mTextView); mTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { buildGoogleApipClient(); mGoogleApiClient.connect(); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(10000); mLocationRequest.setFastestInterval(5000); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if(mLastLocation!=null){ Toast.makeText(this,mLastLocation.getLatitude()+"-----"+mLastLocation.getLongitude(),Toast.LENGTH_LONG).show(); startLocationUpdates(); Toast.makeText(this,mLastLocation.getLatitude()+"-----"+mLastLocation.getLongitude(),Toast.LENGTH_LONG).show();
setContentView(R.layout.activity_main); buildGoogleApiClient(); public void onConnected(@Nullable Bundle bundle) { Log.d(TAG, "Connection established. Fetching location .."); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(1000); mLocationRequest.setFastestInterval(1000); public void onLocationChanged(Location location) { Log.d("Lat: " + location.getLatitude() + "Lng : " + location.getLongitude()); LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
latLng = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude()); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(latLng); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(5000); //5 seconds mLocationRequest.setFastestInterval(3000); //3 seconds
mLocationRequest.setInterval(MIN_TIME_BW_UPDATES); mLocationRequest.setFastestInterval(FAST_TIME_BW_UPDATES); mLocationRequest.setSmallestDisplacement(10); mLocationRequest.setExpirationDuration(EXPIRATION_DURATION); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(mLocationRequest); public void onResult(@NonNull LocationSettingsResult result) { Status status = result.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: displayLocation(); case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: try { status.startResolutionForResult(this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException e) { Log.e("Exception", e.toString());
locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); locationRequest.setInterval(30 * 1000); locationRequest.setNumUpdates(1); locationRequest.setExpirationDuration(20000); locationRequest.setFastestInterval(500); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest); builder.setAlwaysShow(true); //this is the key ingredient final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: { LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this); status.startResolutionForResult(MainTab.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException e) {