本文整理汇总了Java中com.mapzen.android.lost.api.LocationServices类的典型用法代码示例。如果您正苦于以下问题:Java LocationServices类的具体用法?Java LocationServices怎么用?Java LocationServices使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocationServices类属于com.mapzen.android.lost.api包,在下文中一共展示了LocationServices类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestLocationUpdates
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
/**
* Request location updates to the location provider.
*/
@Override
public void requestLocationUpdates() {
LocationRequest request = LocationRequest.create();
if (interval != null) {
request.setInterval(interval);
}
if (fastestInterval != null) {
request.setFastestInterval(fastestInterval);
}
if (smallestDisplacement != null) {
request.setSmallestDisplacement(smallestDisplacement);
}
updateRequestPriority(request);
if (lostApiClient.isConnected()) {
//noinspection MissingPermission
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
}
}
示例2: onConnected
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Override
public void onConnected() {
if (ActivityCompat.checkSelfPermission(tempContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (prefs.getBoolean(Common.PREF_ENABLE_LOCATION_TRACKING, false) && !TextUtils.isEmpty(prefs.getString(Common.PREF_LOCATION_DEVICE_NAME, null))) {
LocationRequest locationRequest = LocationRequest.create()
.setInterval(prefs.getInt(Common.PREF_LOCATION_UPDATE_INTERVAL, 10) * 60 * 1000)
.setFastestInterval(5 * 60 * 1000)
.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, locationRequest, getPendingIntent(tempContext));
Log.d(TAG, "Started requesting location updates");
} else {
LocationServices.FusedLocationApi.removeLocationUpdates(apiClient, getPendingIntent(tempContext));
Log.d(TAG, "Stopped requesting location updates");
}
}
apiClient.disconnect();
tempContext = null;
}
示例3: stopPositionTracking
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
public void stopPositionTracking()
{
if(locationMarker != null)
{
locationMarker.setVisible(false);
accuracyMarker.setVisible(false);
directionMarker.setVisible(false);
}
lastLocation = null;
zoomedYet = false;
isShowingDirection = false;
if(lostApiClient.isConnected())
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
}
lostApiClient.disconnect();
}
示例4: getLastLocation
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
/**
* Returns the Last known location if the location provider is connected.
*
* @return the last known location
*/
@Override
@Nullable
public Location getLastLocation() {
if (lostApiClient.isConnected()) {
//noinspection MissingPermission
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
}
return null;
}
示例5: removeLocationUpdates
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
/**
* Dismiss ongoing location update to the location provider.
*/
@Override
public void removeLocationUpdates() {
if (lostApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
}
}
示例6: setupGeoFence
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
private void setupGeoFence ()
{
//setup geofence for Times Square area
String requestId = "geof1-timesSquare";
double latitude = 40.758896;
double longitude = -73.985130;
float radius = 0.0001f;
Geofence geofence = new Geofence.Builder()
.setRequestId(requestId)
.setCircularRegion(latitude, longitude, radius)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.build();
GeofencingRequest request = new GeofencingRequest.Builder()
.addGeofence(geofence)
.build();
Intent serviceIntent = new Intent(getContext().getApplicationContext(), GeofenceIntentService.class);
PendingIntent pendingIntent = PendingIntent.getService(getContext(), 0, serviceIntent, 0);
try {
LocationServices.GeofencingApi.addGeofences(lostApiClient, request, pendingIntent);
}
catch (SecurityException se)
{
Log.e("GeoTrigger","Permission not granted",se);
}
}
示例7: stopPositionTracking
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
public void stopPositionTracking()
{
if(lostApiClient.isConnected())
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
}
lostApiClient.disconnect();
}
示例8: onConnected
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Override
public void onConnected() throws SecurityException
{
LocationRequest request = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setSmallestDisplacement(500)
.setInterval(3 * 60 * 1000); // 3 minutes
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
}
示例9: stopRequest
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
public void stopRequest()
{
Handler h = new Handler(Looper.getMainLooper());
h.post(() ->
{
if(lostApiClient.isConnected())
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, SingleLocationRequest.this);
}
lostApiClient.disconnect();
});
}
示例10: onConnected
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Override public void onConnected() throws SecurityException
{
zoomedYet = false;
lastLocation = null;
LocationRequest request = LocationRequest.create()
.setInterval(2000)
.setSmallestDisplacement(5)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
}
示例11: onResume
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
locationClient.connect();
MapzenLocation.onLocationServicesConnected(MapController.getMapController(),
LocationServices.FusedLocationApi, (MapzenApplication) getApplication());
}
示例12: onResume
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
if (getMap() != null) {
((AndroidMap) getMap()).pause(false);
}
if (!locationClient.isConnected()) {
locationClient.connect();
}
MapzenLocation.onLocationServicesConnected(MapController.getMapController(),
LocationServices.FusedLocationApi, app);
}
示例13: onDestroy
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Override
public void onDestroy() {
app.activateMoveMapToLocation();
teardownLinedrawing();
markReadyForUpload();
mapController.clearLines();
act.updateView();
bus.unregister(this);
showLocateButton();
if (LocationServices.FusedLocationApi != null) {
LocationServices.FusedLocationApi.setMockMode(false);
}
super.onDestroy();
}
示例14: setup
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Before
public void setup() {
application = (MapzenApplication) Robolectric.application;
application.inject(this);
LocationServices.FusedLocationApi = null;
mapController.setActivity(TestHelper.initBaseActivity());
listener = new MapzenLocation.Listener(application);
}
示例15: shouldSetDefaultLocationUpdateInterval
import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Test
public void shouldSetDefaultLocationUpdateInterval() throws Exception {
FusedLocationProviderApi api = Mockito.mock(FusedLocationProviderApi.class);
LocationServices.FusedLocationApi = api;
ArgumentCaptor<LocationRequest> argument = ArgumentCaptor.forClass(LocationRequest.class);
onLocationServicesConnected(mapController, api, application);
verify(api).requestLocationUpdates(argument.capture(), any(LocationListener.class));
assertThat(argument.getValue().getInterval()).isEqualTo(1000);
}