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


Java GoogleApiClient.blockingConnect方法代码示例

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


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

示例1: initGoogleApiClient

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
private void initGoogleApiClient(GoogleApiClient googleApiClient) {
    if (!googleApiClient.isConnected()) {
        logger.log(TAG, "Google api client is not connected");
        logger.log(TAG, "Google api client connecting");
        ConnectionResult res = googleApiClient.blockingConnect();
        if (!res.isSuccess()) {
            throw new RuntimeException(THROWABLE_KEY_LOCATION);
        }
        logger.log(TAG, "Google api client connected");
    }
}
 
开发者ID:titanium-codes,项目名称:LocGetter,代码行数:12,代码来源:LocationGetterImpl.java

示例2: onDataChanged

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    GoogleApiClient googleApiClient = null;

    for (DataEvent event : dataEventBuffer) {
        if (event.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = event.getDataItem();

        if (CommPaths.COMMAND_ALARM.equals(dataItem.getUri().getPath())) {
            LiteAlarmCommand liteAlarmCommand = ParcelPacker.getParcelable(dataItem.getData(), LiteAlarmCommand.CREATOR);

            if (googleApiClient == null) {
                googleApiClient = new GoogleApiClient.Builder(this)
                        .addApi(Wearable.API)
                        .build();

                googleApiClient.blockingConnect();
            }

            byte[] iconData = getByteArrayAsset(dataItem.getAssets().get(CommPaths.ASSET_ICON), googleApiClient);
            byte[] backgroundData = getByteArrayAsset(dataItem.getAssets().get(CommPaths.ASSET_BACKGROUND), googleApiClient);

            AlarmCommand alarmCommand = new AlarmCommand(liteAlarmCommand, backgroundData, iconData);
            alarm(alarmCommand);

            Wearable.DataApi.deleteDataItems(googleApiClient, dataItem.getUri()).await();
        }
    }

    if (googleApiClient != null) {
        googleApiClient.disconnect();
    }
}
 
开发者ID:matejdro,项目名称:WearVibrationCenter,代码行数:37,代码来源:PhoneCommandListener.java

示例3: getFusedLocation

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
@ReactMethod
public void getFusedLocation( boolean forceNewLocation, final Promise promise) {
    try {
        if (!areProvidersAvailable()) {
            promise.reject(TAG, "No location provider found.");
            return;
        }
        if (!checkForPlayServices()) {
            promise.reject(TAG, "Install Google Play Services First and Try Again.");
            return;
        }
        if (ActivityCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            promise.reject(TAG, "Appropriate permissions not given.");
            return;
        }
        final GoogleApiClient googleApiClient;
        LocationRequest request = buildLR();
        googleApiClient = new GoogleApiClient.Builder(getReactApplicationContext())
                .addApi(LocationServices.API)
                .build();
        googleApiClient.blockingConnect();
        final Location location;
        if(!forceNewLocation) {
            location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
        }
        else {
            location = null;
        }
        if (location == null) {
            LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, new LocationListener() {
                @Override
                public void onLocationChanged(Location l) {
                    LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
                    googleApiClient.disconnect();
                    promise.resolve(convertLocationToJSON(l));
                }
            });
        } else {
            promise.resolve(convertLocationToJSON(location));
            googleApiClient.disconnect();
        }
    } catch (Exception ex) {
        Log.e(TAG, "Native Location Module ERR - " + ex.toString());
        promise.reject(TAG, ex.toString());
    }
}
 
开发者ID:MustansirZia,项目名称:react-native-fused-location,代码行数:47,代码来源:FusedLocationModule.java


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