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


Java LocationResult.extractResult方法代码示例

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


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

示例1: onReceive

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    prefs = Utils.getPrefs(context);
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
        case ACTION_START_LOCATION:
            apiClient = new GoogleApiClient.Builder(context)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(LocationServices.API)
                    .build();

            apiClient.connect();
            break;
        case ACTION_LOCATION_UPDATE:
            if (prefs.getBoolean(Common.PREF_ENABLE_LOCATION_TRACKING, false) && LocationResult.hasResult(intent)) {
                LocationResult result = LocationResult.extractResult(intent);
                Location location = result.getLastLocation();
                if (location != null)
                    logLocation(location, context);
            }
            break;
    }
}
 
开发者ID:Maxr1998,项目名称:home-assistant-Android,代码行数:25,代码来源:LocationUpdateReceiver.java

示例2: 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

示例3: 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

示例4: onHandleIntent

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
     if (mPreferenceUtils.isActivityUpdatesStarted()) {
        if (mPreferenceUtils.isLocationUpdatesStarted()) {
            if (LocationResult.hasResult(intent)) {
                LocationResult locationResult = LocationResult.extractResult(intent);
                Location location = locationResult.getLastLocation();
                saveLocation(location);
            }
            long currentTime = System.currentTimeMillis();
            long tolerance = mPreferenceUtils.getActivityRecognitionToleranceMillis();
            long lastActivityTime = mPreferenceUtils.getLastActivityTime();
            long elapsedTime = currentTime - lastActivityTime;
            if (elapsedTime > tolerance) {
                mLocationUpdatesController.stopLocationUpdates();
            }
        }
    }
}
 
开发者ID:rubenlop88,项目名称:autotracks-android,代码行数:20,代码来源:LocationUpdatesService.java

示例5: onStartCommand

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@WorkerThread
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    count++;
    if (LocationResult.hasResult(intent)) {
        // 從fusedLocationApi取得位置資料
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            succeed++;

            // 若小於最小間距,則不紀錄該航跡
            if (mTrkpts.size() > 1) {
                double interval = SphericalUtil.computeDistanceBetween(
                        new LatLng(location.getLatitude(), location.getLongitude()),
                        new LatLng(mLastPosition.getLatitude(), mLastPosition.getLongitude()));
                if (interval < DISTANCE_INTERVAL_FOR_TRKPTS)
                    return START_STICKY;
            }

            mTrkpts.add(location);
            mLastPosition = location;

            // Send Location Update to Activity
            if (callBack != null)
                callBack.getServiceData(location);
        }
    }

    // Message for testing
    Log.d(TAG, "Record Times: " + count + ", Succeed times: " + succeed +
            ",  Points number: " + mTrkpts.size()
            + ", Time from start: " + (new Date().getTime() - startTime) / 1000);

    return START_STICKY;
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:37,代码来源:TrackingService.java

示例6: onReceive

import com.google.android.gms.location.LocationResult; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (LocationResult.hasResult(intent)) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude());
            adapter.notifyDataSetChanged();
        }
    }
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:12,代码来源:ProductSoldFragmentPersonal.java

示例7: 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

示例8: 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.extractResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。