当前位置: 首页>>代码示例>>Java>>正文


Java LocationResult.getLocations方法代码示例

本文整理汇总了Java中com.google.android.gms.location.LocationResult.getLocations方法的典型用法代码示例。如果您正苦于以下问题:Java LocationResult.getLocations方法的具体用法?Java LocationResult.getLocations怎么用?Java LocationResult.getLocations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.location.LocationResult的用法示例。


在下文中一共展示了LocationResult.getLocations方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                LocationResultHelper locationResultHelper = new LocationResultHelper(
                        context, locations);
                // Save the location data to SharedPreferences.
                locationResultHelper.saveResults();
                // Show notification with the location data.
                locationResultHelper.showNotification();
                Log.i(TAG, LocationResultHelper.getSavedLocationResult(context));
            }
        }
    }
}
 
开发者ID:googlecodelabs,项目名称:background-location-updates-android-o,代码行数:20,代码来源:LocationUpdatesBroadcastReceiver.java

示例2: onHandleIntent

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                LocationResultHelper locationResultHelper = new LocationResultHelper(this,
                        locations);
                // Save the location data to SharedPreferences.
                locationResultHelper.saveResults();
                // Show notification with the location data.
                locationResultHelper.showNotification();
                Log.i(TAG, LocationResultHelper.getSavedLocationResult(this));
            }
        }
    }
}
 
开发者ID:googlecodelabs,项目名称:background-location-updates-android-o,代码行数:20,代码来源:LocationUpdatesIntentService.java

示例3: onLocationResult

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override public void onLocationResult(LocationResult locationResult) {
  for (Location location : locationResult.getLocations()) {
    Log.i("Debug ", "On Location Available " + location.toString());
    currentLocation = location;
    matchForCheckPoints();
  }
}
 
开发者ID:Arjun-sna,项目名称:LocationAware,代码行数:8,代码来源:LocationAwareService.java

示例4: onCreate

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
public void onCreate() {
    EventBus.getDefault().register(this);

    // Start up the thread running the service.  Note that we create a
    // separate thread because the service normally runs in the process's
    // main thread, which we don't want to block.  We also make it
    // background priority so CPU-intensive work will not disrupt our UI.
    HandlerThread thread = new HandlerThread("LocationServiceThread",
            Thread.MIN_PRIORITY);
    thread.start();

    // Get the HandlerThread's Looper and use it for our Handler
    mServiceLooper = thread.getLooper();
    mServiceHandler = new Handler(mServiceLooper);

    mServiceHandler.handleMessage(new Message());

    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this.getApplicationContext());
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    /* Create the Gpx instance */
    mTrackPoints = new ArrayList<>();

    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            for (Location location : locationResult.getLocations()) {
                mServiceHandler.post(() -> {
                    TrackPoint.Builder pointBuilder = new TrackPoint.Builder();
                    pointBuilder.setLatitude(location.getLatitude());
                    pointBuilder.setLongitude(location.getLongitude());
                    pointBuilder.setElevation(location.getAltitude());

                    TrackPoint trackPoint = pointBuilder.build();
                    mTrackPoints.add(trackPoint);
                });
            }
        }
    };

    startLocationUpdates();
}
 
开发者ID:peterLaurence,项目名称:TrekAdvisor,代码行数:47,代码来源:LocationService.java

示例5: onAttach

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof RequestManageTracksListener
            && context instanceof RequestManageMarkerListener
            && context instanceof MapProvider) {
        mRequestManageTracksListener = (RequestManageTracksListener) context;
        mRequestManageMarkerListener = (RequestManageMarkerListener) context;
        mMapProvider = (MapProvider) context;
    } else {
        throw new RuntimeException(context.toString()
                + " must implement RequestManageTracksListener, MapProvider and LocationProvider");
    }

    /* The Google api client is re-created here as the onAttach method will always be called for
     * a retained fragment.
     */
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this.getActivity().getApplicationContext());
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            for (Location location : locationResult.getLocations()) {
                onLocationReceived(location);
            }
        }
    };
}
 
开发者ID:peterLaurence,项目名称:TrekAdvisor,代码行数:33,代码来源:MapViewFragment.java

示例6: onReceive

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                Utils.setLocationUpdatesResult(context, locations);
                Utils.sendNotification(context, Utils.getLocationResultTitle(context, locations));
                Log.i(TAG, Utils.getLocationUpdatesResult(context));
            }
        }
    }
}
 
开发者ID:googlesamples,项目名称:android-play-location,代码行数:16,代码来源:LocationUpdatesBroadcastReceiver.java

示例7: onHandleIntent

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                Utils.setLocationUpdatesResult(this, locations);
                Utils.sendNotification(this, Utils.getLocationResultTitle(this, locations));
                Log.i(TAG, Utils.getLocationUpdatesResult(this));
            }
        }
    }
}
 
开发者ID:googlesamples,项目名称:android-play-location,代码行数:16,代码来源:LocationUpdatesIntentService.java


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