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


Java LocationAvailability类代码示例

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


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

示例1: requestLocationAvailabilityUpdates

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Observable<LocationAvailability> requestLocationAvailabilityUpdates(LocationRequest
                                                                                   request) {
    return ObservableTask.create(callback -> {
        LocationCallback resultCallback = new LocationCallback() {
            @Override
            public void onLocationAvailability(LocationAvailability locationAvailability) {
                super.onLocationAvailability(locationAvailability);
                callback.onNext(locationAvailability);
            }
        };
        callback.setDisposeListener(() -> client.removeLocationUpdates(resultCallback));
        return client.requestLocationUpdates(request, resultCallback, null);

    });
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:21,代码来源:RxFusedLocationProviderClient.java

示例2: SendLocation

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
public void SendLocation(){
    try {
        LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
        if (locationAvailability.isLocationAvailable()) {
            // Call Location Services
            LocationRequest locationRequest = new LocationRequest()
                    .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                    .setInterval(10000)//10second
                    .setFastestInterval(5000);//5second
            LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
            Log.v("SendLocation",locationAvailability.toString());
        } else {
            // Do something when Location Provider not available
            Toast.makeText(getApplicationContext()
                    , "Please Open Location Provider"
                    , Toast.LENGTH_SHORT).show();
        }
    }
    catch (Exception e){
        Log.v("SendLocation exception",e.toString());
    }
}
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:23,代码来源:RSSPullService.java

示例3: onGoogleApiClientReady

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter<Boolean> emitter) {
    //noinspection MissingPermission
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(apiClient);

    if (locationAvailability != null) {
        emitter.onSuccess(locationAvailability.isLocationAvailable());
    } else {
        emitter.onSuccess(false);
    }
}
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:12,代码来源:LocationAvailabilitySingleOnSubscribe.java

示例4: getLocationAvailability

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Maybe<LocationAvailability> getLocationAvailability() {
    return MaybeTask.create(() -> client.getLocationAvailability());
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:9,代码来源:RxFusedLocationProviderClient.java

示例5: run

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
@SuppressLint("MissingPermission")
@Override
protected Task<Void> run(ObservableTaskCallback<LocationAvailability> callback) {
    ResultCallback resultCallback = new ResultCallback(callback);
    callback.setDisposeListener(() -> client.removeLocationUpdates(resultCallback));
    return client.requestLocationUpdates(this.request, resultCallback, null);
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:8,代码来源:RequestLocationAvailabilityObservable.java

示例6: checkLocationAvailability

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
private boolean checkLocationAvailability() {
    if (!googleApiClient.isConnected() || !permissionGranted) return false;
    try {
        LocationAvailability la = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
        return (la != null && la.isLocationAvailable());
    } catch (SecurityException e) {
        if (!quiet)
            Log.e(getClass().getSimpleName(), "Error while checking location availability:\n " + e.toString());
        if (listener != null)
            listener.onError(ErrorType.RETRIEVAL, "Could not check location availability:\n" +
                    e.getMessage());
        return false;
    }
}
 
开发者ID:klaasnotfound,项目名称:LocationAssistant,代码行数:15,代码来源:LocationAssistant.java

示例7: handleMessage

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
public final void handleMessage(Message paramMessage)
{
  switch (paramMessage.what)
  {
  default: 
    return;
  case 0: 
    this.a.a((LocationResult)paramMessage.obj);
    return;
  }
  this.a.a((LocationAvailability)paramMessage.obj);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:13,代码来源:fda.java

示例8: onConnected

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
@Override
public void onConnected(final Bundle bundle) {
    if (! mGoogleApiClient.isConnected()) {
        Log.w("OpenLocationCodes", "GoogleApiClient was disconnected");
        return;
    }
    if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED) {
        // TODO
        return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this).setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(@NonNull final Status status) {
            if (status.isSuccess()) {
                Log.d("OpenLocationCodes", "LocationServices: SUCCESS");
                final LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(mGoogleApiClient);
                if (locationAvailability != null && locationAvailability.isLocationAvailable()) {
                    onLocationChanged(LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient));
                }
            } else if (status.isCanceled()) {
                Log.d("OpenLocationCodes", "LocationServices: CANCELED");
            } else if (status.isInterrupted()) {
                Log.d("OpenLocationCodes", "LocationServices: INTERRUPTED");
            }
        }
    });
}
 
开发者ID:shkschneider,项目名称:android_OpenLocationCodes,代码行数:28,代码来源:Locator.java

示例9: insertGyroTOserver

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
public void insertGyroTOserver(final String dt,final String x, final String y, final String z)
    {
        if(lat!=0 || lng!=0) {
            try {
                LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
                if (locationAvailability.isLocationAvailable()) {
                    // Call Location Services
                    LocationRequest locationRequest = new LocationRequest()
                            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
                    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
                }
//                String queryString = createQueryString(params);
                final String SITE_URL = "http://168.63.175.28/addGyro.php";
                TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                RequestBody formBody = new FormEncodingBuilder()
                        .add("isAdd", "true")
                        .add("imei", telephonyManager.getDeviceId())
                        .add("time",dt)
                        .add("x", x)
                        .add("y", y)
                        .add("z", z)
                        .add("lat",String.valueOf(lat))
                        .add("lng",String.valueOf(lng))
                        .build();
                PostForm p= new PostForm(formBody,SITE_URL);
                final Toast toast = Toast.makeText(getApplicationContext(), "มีการกระแทกเกิดขึ้น", Toast.LENGTH_SHORT);
//                toast.show();
            }
            catch (Exception ex) {
                Log.v("ex", ex.toString());
            }
        }
    }
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:34,代码来源:RSSPullService.java

示例10: Start

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
public void Start(View view){
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
    if (locationAvailability.isLocationAvailable()) {
        // Call Location Services
        LocationRequest locationRequest = new LocationRequest()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    } else {
        // Do something when Location Provider not available
    }
}
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:12,代码来源:GoogleLocation.java

示例11: Stop

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
public void Stop(View view){
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
    if (locationAvailability.isLocationAvailable()) {
        // Call Location Services
        LocationRequest locationRequest = new LocationRequest()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    } else {
        // Do something when Location Provider not available
    }
}
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:12,代码来源:GoogleLocation.java

示例12: onConnected

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
@Override
public void onConnected(Bundle connectionHint) {
    Log.i("CaptureActivity", "onConnected called");
    clientReady = true;

    //Use a new thread to request location updates for the worker thread.
    //This new thread waits until the result of the request for updates is complete.
    Runnable r = new Runnable(){
        @Override
        public void run() {
            LocationRequest request = new LocationRequest();
            request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(5000);

            LocationCallback locationCallback = new LocationCallback() {
                @Override
                public void onLocationAvailability(LocationAvailability availability) {
                    if (!availability.isLocationAvailable()) {
                        locationReady = false;
                    }
                }

                public void onLocationResult(LocationResult result) {
                    newestLocation = result.getLastLocation();
                }
            };

            PendingResult<Status> requestResult = LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, locationCallback, handler.getLooper());
            Status requestStatus = requestResult.await();
            locationReady = true;
            if(requestStatus.isSuccess()) {
                locationReady = true;
                Log.i("CaptureActivity", "Location update request result success!");
            }else {
                Log.i("CaptureActivity", "Location update request result: failure!");
            }
        }
    };
    new Thread(r).start();
}
 
开发者ID:fultonms,项目名称:drivedata,代码行数:40,代码来源:CaptureActivity.java

示例13: onLocationAvailability

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
@Override public void onLocationAvailability(LocationAvailability locationAvailability) {
  Log.i("Debug ", "On Location availability");
}
 
开发者ID:Arjun-sna,项目名称:LocationAware,代码行数:4,代码来源:LocationAwareService.java

示例14: ResultCallback

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
public ResultCallback(ObservableTaskCallback<LocationAvailability> callback) {
    this.callback = callback;
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:4,代码来源:RequestLocationAvailabilityObservable.java

示例15: onLocationAvailability

import com.google.android.gms.location.LocationAvailability; //导入依赖的package包/类
public void onLocationAvailability(LocationAvailability result) {
    super.onLocationAvailability(result);
    callback.onNext(result);
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:5,代码来源:RequestLocationAvailabilityObservable.java


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