當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。