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


Java PendingResult类代码示例

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


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

示例1: displayLocationSettingsRequest

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
public void displayLocationSettingsRequest(final Activity activity) {
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(activity)
            .addApi(LocationServices.API).build();
    googleApiClient.connect();

    LocationRequest locationRequest = LocationRequest.create();
    locationRequest.setPriority(mAccuracy);
    locationRequest.setInterval(mInterval);
    locationRequest.setFastestInterval(mInterval / 2);

    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
            .addLocationRequest(locationRequest);
    builder.setAlwaysShow(false);

    final PendingResult<LocationSettingsResult> result =
            LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build());
    result.setResultCallback(new LocationResultCallback(activity));
}
 
开发者ID:philiWeitz,项目名称:react-native-location-switch,代码行数:19,代码来源:LocationSwitch.java

示例2: onConfigurationAddedOrEdited

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
/**
 * Synchronizes the UART configurations between handheld and wearables.
 * Call this when configuration has been created or altered.
 * @return pending result
 */
public PendingResult<DataApi.DataItemResult> onConfigurationAddedOrEdited(final long id, final UartConfiguration configuration) {
	if (mGoogleApiClient == null || !mGoogleApiClient.isConnected())
		return null;

	final PutDataMapRequest mapRequest = PutDataMapRequest.create(Constants.UART.CONFIGURATIONS + "/" + id);
	final DataMap map = mapRequest.getDataMap();
	map.putString(Constants.UART.Configuration.NAME, configuration.getName());
	final ArrayList<DataMap> commands = new ArrayList<>(UartConfiguration.COMMANDS_COUNT);
	for (Command command : configuration.getCommands()) {
		if (command != null && command.isActive()) {
			final DataMap item = new DataMap();
			item.putInt(Constants.UART.Configuration.Command.ICON_ID, command.getIconIndex());
			item.putString(Constants.UART.Configuration.Command.MESSAGE, command.getCommand());
			item.putInt(Constants.UART.Configuration.Command.EOL, command.getEolIndex());
			commands.add(item);
		}
	}
	map.putDataMapArrayList(Constants.UART.Configuration.COMMANDS, commands);
	final PutDataRequest request = mapRequest.asPutDataRequest();
	return Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:27,代码来源:UARTConfigurationSynchronizer.java

示例3: refreshPlacesData

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
public void refreshPlacesData(){
    Uri uri = PlacesContract.PlaceEntry.CONTENT_URI;
    Cursor dataCursor = getContentResolver().query(uri,
            null,
            null,
            null,null,null);
    if (dataCursor==null||dataCursor.getCount()==0) return;
    List<String> placeIds = new ArrayList<String>();
    while (dataCursor.moveToNext()){
        placeIds.add(dataCursor.getString(dataCursor.getColumnIndex(PlacesContract.PlaceEntry.COLUMN_PLACE_ID)));
    }
    PendingResult<PlaceBuffer> placeBufferPendingResult = Places.GeoDataApi.getPlaceById(mClient,
            placeIds.toArray(new String[placeIds.size()]));
    placeBufferPendingResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
        @Override
        public void onResult(@NonNull PlaceBuffer places) {
            mAdapter.swapPlaces(places);
            mGeofencing.updateGeofencesList(places);
            if (mIsEnabled) mGeofencing.registerAllGeofences();
        }
    });
}
 
开发者ID:samagra14,项目名称:Shush,代码行数:23,代码来源:MainActivity.java

示例4: updateWearWeather

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
private void updateWearWeather(int weather_id, double high_temp, double low_temp){
    PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(WEATHER_PATH).setUrgent();
    putDataMapRequest.getDataMap().putInt(WEATHER_ID, weather_id);
    Log.d(LOG_TAG, "value of weather put : "+weather_id);
    putDataMapRequest.getDataMap().putDouble(HIGH_TEMP, high_temp);
    putDataMapRequest.getDataMap().putDouble(LOW_TEMP, low_temp);
    PutDataRequest putDataRequest = putDataMapRequest.asPutDataRequest().setUrgent();
    PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mWearClient, putDataRequest);

    pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
        @Override
        public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
            if (dataItemResult.getStatus().isSuccess()) {
                Log.d(LOG_TAG, "Data item set: " + dataItemResult.getDataItem().getUri());

            } else {
                Log.d(LOG_TAG, "Error in sending data to watch");
            }
        }

    });
}
 
开发者ID:rashikaranpuria,项目名称:ubiquitous,代码行数:23,代码来源:SunshineSyncIntentService.java

示例5: getAutocomplete

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
private ArrayList<AutocompletePrediction> getAutocomplete(CharSequence constraint) {
    if (mGoogleApiClient.isConnected()) {

        PendingResult<AutocompletePredictionBuffer> results =
                Places.GeoDataApi
                        .getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
                                mBounds, mPlaceFilter);

        AutocompletePredictionBuffer autocompletePredictions = results
                .await(60, TimeUnit.SECONDS);

        final Status status = autocompletePredictions.getStatus();
        if (!status.isSuccess()) {
            Toast.makeText(getContext(), "Error contacting API: " + status.toString(),
                    Toast.LENGTH_SHORT).show();
            autocompletePredictions.release();
            return null;
        }
        return DataBufferUtils.freezeAndClose(autocompletePredictions);
    }
    return null;
}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:23,代码来源:PlaceAutocompleteAdapter.java

示例6: getAutocompleteResults

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
public Observable<PlacePrediction> getAutocompleteResults(final GoogleApiClient mGoogleApiClient, final String query, final LatLngBounds bounds) {
    return Observable.create(new Observable.OnSubscribe<PlacePrediction>() {
        @Override
        public void call(Subscriber<? super PlacePrediction> subscriber) {

            PendingResult<AutocompletePredictionBuffer> results =
                    Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, query,
                            bounds, null);

            AutocompletePredictionBuffer autocompletePredictions = results
                    .await(60, TimeUnit.SECONDS);

            final Status status = autocompletePredictions.getStatus();
            if (!status.isSuccess()) {
                autocompletePredictions.release();
                subscriber.onError(null);
            } else {
                for (AutocompletePrediction autocompletePrediction : autocompletePredictions) {
                    subscriber.onNext(
                            new PlacePrediction(
                                    autocompletePrediction.getPlaceId(),
                                    autocompletePrediction.getDescription()
                            ));
                }
                autocompletePredictions.release();
                subscriber.onCompleted();
            }
        }
    });
}
 
开发者ID:sathishmscict,项目名称:Pickr,代码行数:31,代码来源:DataManager.java

示例7: call

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::revealAchievement" );
	String achievementId = FREObjectUtils.getString( args[0] );
	boolean immediate = FREObjectUtils.getBoolean( args[1] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.revealImmediate( helper.getClient(), achievementId );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.reveal( helper.getClient(), achievementId );
		AIR.log( "Successfully revealed achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:26,代码来源:RevealAchievementFunction.java

示例8: getAutocomplete

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
private ArrayList<AutocompletePrediction> getAutocomplete(CharSequence constraint) {
  if (mGoogleApiClient.isConnected()) {
    PendingResult<AutocompletePredictionBuffer> results =
        Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
            mBounds, mPlaceFilter);

    AutocompletePredictionBuffer autocompletePredictions = results.await(60, TimeUnit.SECONDS);

    final Status status = autocompletePredictions.getStatus();
    if (!status.isSuccess()) {
      Toast.makeText(getContext(), "Error contacting API: " + status.toString(),
          Toast.LENGTH_SHORT).show();
      autocompletePredictions.release();
      return null;
    }

    return DataBufferUtils.freezeAndClose(autocompletePredictions);
  }
  return null;
}
 
开发者ID:jotaramirez90,项目名称:AutocompleteLocation,代码行数:21,代码来源:AutoCompleteAdapter.java

示例9: delete

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
@Override
public PendingResult<DeleteSnapshotResult> delete(GoogleApiClient googleApiClient,
                                                  final SnapshotMetadata snapshotMetadata) {
    if (!isAlreadyOpen(snapshotMetadata.getUniqueName()) &&
            !isAlreadyClosing(snapshotMetadata.getUniqueName())) {
        setIsClosing(snapshotMetadata.getUniqueName());
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.delete(googleApiClient, snapshotMetadata),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            // deleted files are closed.
                            setClosed(snapshotMetadata.getUniqueName());
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshotMetadata.getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshotMetadata.getUniqueName() +
                " is either open or is busy");
    }
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:26,代码来源:SnapshotCoordinator.java

示例10: callPlaceDetectionApi

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
            }
            likelyPlaces.release();
        }
    });
}
 
开发者ID:addy-org,项目名称:Addy-Android,代码行数:17,代码来源:PlacesAPIActivity.java

示例11: startLocationUpdates

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
@SuppressWarnings({"MissingPermission"})
public void startLocationUpdates(GoogleApiClient googleApiClient) {
    // particular case:hace un requestLocationSettings y casi al mismo tiempo  stop(),
    // ,se recibe settingsResult:SUCCESS y luego hace startLocationUpdates y como
    // no está conectado da error
    if (!googleApiClient.isConnected()) {
        return;
    }

    PendingResult<Status> result = LocationServices.FusedLocationApi.requestLocationUpdates(
            googleApiClient, mLocationRequest, this);
    result.setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(@NonNull Status status) {
            if (!status.isSuccess()) {

                Utils.logD(LOG_TAG, String.format("requestLocationUpdates returned an error:code:%s ," +
                        "message: %s", status.getStatusCode(), status.getStatusMessage()));

                getActivity().finish();
            }
        }
    }, 2, TimeUnit.SECONDS);

}
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:26,代码来源:GPSTrackerFragment.java

示例12: findAllWearDevices

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
@SuppressLint("LongLogTag")
private void findAllWearDevices() {
    Log.d(TAG, "findAllWearDevices()");

    PendingResult<NodeApi.GetConnectedNodesResult> pendingResult =
            Wearable.NodeApi.getConnectedNodes(mGoogleApiClient);

    pendingResult.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
        @Override
        public void onResult(@NonNull NodeApi.GetConnectedNodesResult getConnectedNodesResult) {

            if (getConnectedNodesResult.getStatus().isSuccess()) {
                mAllConnectedNodes = getConnectedNodesResult.getNodes();
                verifyNodeAndUpdateUI();
                Log.e("Connected Nodes", "->"+mAllConnectedNodes.toString());
                findWearDevicesWithApp();

            } else {
                Log.d(TAG, "Failed NodeApi: " + getConnectedNodesResult.getStatus());
            }
        }
    });
}
 
开发者ID:squareboat,项目名称:Excuser,代码行数:24,代码来源:DeviceWearConnectionFragment.java

示例13: onConnected

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
@Override
public void onConnected(Bundle bundle) {

    //inicializa list view
    adapter=new ArrayAdapter<Location>(this, android.R.layout.simple_list_item_1, data);
    setListAdapter(adapter);

    //define requisicao para obter localizacao
    //objeto define quantos updates serao necessarios
    //deadline para desistir se nao conseguir obter location
    //intervalo
    //otimizacao de energia, caso aplicavel
    locationRequest = new LocationRequest()
            .setNumUpdates(5)
            .setExpirationDuration(60000)
            .setInterval(1000)
            .setPriority(LocationRequest.PRIORITY_LOW_POWER);


    LocationSettingsRequest.Builder b = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(playServices, b.build());
    result.setResultCallback(this);
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:24,代码来源:FusedLocationMapActivity.java

示例14: getAutocomplete

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
private ArrayList<AutocompletePrediction> getAutocomplete(CharSequence constraint) {
	if (mGoogleApiClient.isConnected()) {
		PendingResult<AutocompletePredictionBuffer> results =
                  Places.GeoDataApi
			.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
										mBounds, mPlaceFilter);
 				AutocompletePredictionBuffer autocompletePredictions = results
                  .await(60, TimeUnit.SECONDS);
				final Status status = autocompletePredictions.getStatus();
		if (!status.isSuccess()) {
			if (callback != null) callback.onSuggestFail(status);
			autocompletePredictions.release();
			return null;
		}
			return DataBufferUtils.freezeAndClose(autocompletePredictions);
	}
		return null;
}
 
开发者ID:agusibrahim,项目名称:go-jay,代码行数:19,代码来源:PlaceAutoCompleteHelper.java

示例15: callPlaceDetectionApi

import com.google.android.gms.common.api.PendingResult; //导入依赖的package包/类
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
                display.setText(placeLikelihood.getPlace().getAddress().toString());
                messageSending(placeLikelihood.getPlace().getAddress().toString());
                break;
            }
            likelyPlaces.release();
        }
    });
}
 
开发者ID:Pritom14,项目名称:Gps,代码行数:20,代码来源:Gps4Activity.java


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