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


Java FusedLocationProviderClient类代码示例

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


FusedLocationProviderClient类属于com.google.android.gms.location包,在下文中一共展示了FusedLocationProviderClient类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerForLocationUpdates

import com.google.android.gms.location.FusedLocationProviderClient; //导入依赖的package包/类
@DebugLog
@SuppressLint("MissingPermission")
void registerForLocationUpdates() {
    FusedLocationProviderClient locationProviderClient = getFusedLocationProviderClient();
    LocationRequest locationRequest = LocationRequest.create();
    Looper looper = Looper.myLooper();
    locationProviderClient.requestLocationUpdates(locationRequest, locationCallback, looper);
}
 
开发者ID:StylingAndroid,项目名称:LocationServices,代码行数:9,代码来源:LocationFragment.java

示例2: getFusedLocationProviderClient

import com.google.android.gms.location.FusedLocationProviderClient; //导入依赖的package包/类
@DebugLog
@NonNull
private FusedLocationProviderClient getFusedLocationProviderClient() {
    if (fusedLocationProviderClient == null) {
        fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(getActivity());
    }
    return fusedLocationProviderClient;
}
 
开发者ID:StylingAndroid,项目名称:LocationServices,代码行数:9,代码来源:LocationFragment.java

示例3: PositionProvider

import com.google.android.gms.location.FusedLocationProviderClient; //导入依赖的package包/类
private PositionProvider(Context context) {
    Log.d(TAG, "Constructor");
    fusedLocationProviderClient = new FusedLocationProviderClient(context);
    locationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            Log.d(TAG, "onLocationResult");
            onLocationChanged(locationResult.getLastLocation());
        }
    };
    listeners = new SortedList<>(PositionProviderListener.class, new InnerCallback());
    buildGoogleApiClient(context);
    Location location = new Location("");

    double last_latitude = Double.longBitsToDouble(TranSappApplication.getAppSharedPreferences()
            .getLong(PositionProvider.USER_LATITUDE, 0));
    last_latitude = last_latitude != 0 ? last_latitude : Constants.santiagoLatitude;

    double last_longitude = Double.longBitsToDouble(TranSappApplication.getAppSharedPreferences()
            .getLong(PositionProvider.USER_LONGITUDE, 0));
    last_longitude = last_longitude != 0 ? last_longitude : Constants.santiagoLongitude;

    Log.d(TAG, "load latitude: " + last_latitude);
    Log.d(TAG, "load longitude: " + last_longitude);
    location.setLatitude(last_latitude);
    location.setLongitude(last_longitude);
    lasKnownLocation = location;
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:29,代码来源:PositionProvider.java

示例4: RequestLocationResultObservable

import com.google.android.gms.location.FusedLocationProviderClient; //导入依赖的package包/类
public RequestLocationResultObservable(FusedLocationProviderClient client, LocationRequest request) {
    this.client = client;
    this.request = request;
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:5,代码来源:RequestLocationResultObservable.java

示例5: RequestLocationAvailabilityObservable

import com.google.android.gms.location.FusedLocationProviderClient; //导入依赖的package包/类
public RequestLocationAvailabilityObservable(FusedLocationProviderClient client, LocationRequest
        request) {
    this.client = client;
    this.request = request;
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:6,代码来源:RequestLocationAvailabilityObservable.java

示例6: updateTransitionsByLastKnownLocation

import com.google.android.gms.location.FusedLocationProviderClient; //导入依赖的package包/类
@SuppressLint("MissingPermission")
void updateTransitionsByLastKnownLocation(final boolean startEventsHandler) {
    try {
        if (Permissions.checkLocation(context) && (mGoogleApiClient != null) && mGoogleApiClient.isConnected()) {
            PPApplication.logE("GeofenceScanner.updateTransitionsByLastKnownLocation", "xxx");
            FusedLocationProviderClient fusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
            final Context appContext = context.getApplicationContext();
            //noinspection MissingPermission
            fusedLocationClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
                @Override
                public void onSuccess(Location location) {
                    // Got last known location. In some rare situations this can be null.
                    PPApplication.logE("GeofenceScanner.updateTransitionsByLastKnownLocation", "onSuccess");
                    if (location != null) {
                        synchronized (PPApplication.geofenceScannerLastLocationMutex) {
                            lastLocation.set(location);
                        }
                        PPApplication.startHandlerThread();
                        final Handler handler = new Handler(PPApplication.handlerThread.getLooper());
                        handler.post(new Runnable() {
                            @Override
                            public void run() {
                                PowerManager powerManager = (PowerManager) appContext.getSystemService(POWER_SERVICE);
                                PowerManager.WakeLock wakeLock = null;
                                if (powerManager != null) {
                                    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "GeofenceScanner.updateTransitionsByLastKnownLocation");
                                    wakeLock.acquire(10 * 60 * 1000);
                                }

                                updateGeofencesInDB();
                                if (startEventsHandler) {
                                    // start job
                                    //EventsHandlerJob.startForSensor(appContext, EventsHandler.SENSOR_TYPE_LOCATION_MODE);
                                    EventsHandler eventsHandler = new EventsHandler(appContext);
                                    eventsHandler.handleEvents(EventsHandler.SENSOR_TYPE_LOCATION_MODE/*, false*/);
                                }

                                if ((wakeLock != null) && wakeLock.isHeld())
                                    wakeLock.release();
                            }
                        });
                    }
                }
            });
        }
    } catch (Exception ignored) {}
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:48,代码来源:GeofencesScanner.java


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