• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LocationServices类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mapzen.android.lost.api.LocationServices的典型用法代码示例。如果您正苦于以下问题:Java LocationServices类的具体用法?Java LocationServices怎么用?Java LocationServices使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LocationServices类属于com.mapzen.android.lost.api包,在下文中一共展示了LocationServices类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:25,代码来源:LostLocationEngine.java


示例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;
}
 
开发者ID:Maxr1998,项目名称:home-assistant-Android,代码行数:19,代码来源:LocationUpdateReceiver.java


示例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();
}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:19,代码来源:MapFragment.java


示例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;
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:15,代码来源:LostLocationEngine.java


示例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);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:10,代码来源:LostLocationEngine.java


示例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);
    }
}
 
开发者ID:n8fr8,项目名称:PanicKitSamples,代码行数:31,代码来源:GeoTrigger.java


示例7: stopPositionTracking

import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
public void stopPositionTracking()
{
	if(lostApiClient.isConnected())
	{
		LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
	}
	lostApiClient.disconnect();
}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:9,代码来源:QuestAutoSyncer.java


示例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);
}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:11,代码来源:QuestAutoSyncer.java


示例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();
	});

}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:14,代码来源:SingleLocationRequest.java


示例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);
}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:13,代码来源:MapFragment.java


示例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());
}
 
开发者ID:mapzen,项目名称:open,代码行数:8,代码来源:LoginActivity.java


示例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);
}
 
开发者ID:mapzen,项目名称:open,代码行数:15,代码来源:BaseActivity.java


示例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();
}
 
开发者ID:mapzen,项目名称:open,代码行数:16,代码来源:RouteFragment.java


示例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);
}
 
开发者ID:mapzen,项目名称:open,代码行数:9,代码来源:MapzenLocationTest.java


示例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);
}
 
开发者ID:mapzen,项目名称:open,代码行数:10,代码来源:MapzenLocationTest.java


示例16: shouldSetCustomLocationUpdateInterval

import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Test
public void shouldSetCustomLocationUpdateInterval() throws Exception {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(application);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putInt(application.getString(R.string.settings_location_update_interval_key), 2000);
    editor.commit();

    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(2000);
}
 
开发者ID:mapzen,项目名称:open,代码行数:15,代码来源:MapzenLocationTest.java


示例17: onLocationServicesConnected_shouldUpdateMapController

import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Test
public void onLocationServicesConnected_shouldUpdateMapController() throws Exception {
    Location expected = initLastLocation();
    onLocationServicesConnected(mapController, LocationServices.FusedLocationApi, application);
    Location actual = mapController.getLocation();
    assertThat(actual).isEqualTo(expected);
}
 
开发者ID:mapzen,项目名称:open,代码行数:8,代码来源:MapzenLocationTest.java


示例18: onLocationServicesConnected_shouldResetZoomLevel

import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Test
public void onLocationServicesConnected_shouldResetZoomLevel() throws Exception {
    mapController.setZoomLevel(1);
    initLastLocation();
    onLocationServicesConnected(mapController, LocationServices.FusedLocationApi, application);
    assertThat(mapController.getZoomLevel()).isEqualTo(MapController.DEFAULT_ZOOM_LEVEL);
}
 
开发者ID:mapzen,项目名称:open,代码行数:8,代码来源:MapzenLocationTest.java


示例19: onLocationServicesConnected_shouldSetPriority

import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Test
public void onLocationServicesConnected_shouldSetPriority() 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().getPriority()).isEqualTo(PRIORITY_HIGH_ACCURACY);
}
 
开发者ID:mapzen,项目名称:open,代码行数:10,代码来源:MapzenLocationTest.java


示例20: shouldNotifyUserIfLastLocationNotAvailable

import com.mapzen.android.lost.api.LocationServices; //导入依赖的package包/类
@Test
public void shouldNotifyUserIfLastLocationNotAvailable() throws Exception {
    LocationManager locationManager = (LocationManager)
            application.getSystemService(Context.LOCATION_SERVICE);
    shadowOf(locationManager).setLastKnownLocation(LocationManager.GPS_PROVIDER, null);
    shadowOf(locationManager).setLastKnownLocation(LocationManager.NETWORK_PROVIDER, null);
    shadowOf(locationManager).setLastKnownLocation(LocationManager.GPS_PROVIDER, null);
    onLocationServicesConnected(mapController, LocationServices.FusedLocationApi, application);
    assertThat(getTextOfLatestToast()).isEqualTo(application.getString(R.string.waiting));
}
 
开发者ID:mapzen,项目名称:open,代码行数:11,代码来源:MapzenLocationTest.java



注:本文中的com.mapzen.android.lost.api.LocationServices类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VectorialCovariance类代码示例发布时间:2022-05-22
下一篇:
Java NBTTagInt类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap