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


Java PendingResult.setResultCallback方法代码示例

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


在下文中一共展示了PendingResult.setResultCallback方法的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: populateConfigurations

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
/**
 * This method read the UART configurations from the DataApi and populates the adapter with them.
 */
private void populateConfigurations() {
	if (mGoogleApiClient.isConnected()) {
		final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX);
		results.setResultCallback(new ResultCallback<DataItemBuffer>() {
			@Override
			public void onResult(final DataItemBuffer dataItems) {
				final List<UartConfiguration> configurations = new ArrayList<>(dataItems.getCount());
				for (int i = 0; i < dataItems.getCount(); ++i) {
					final DataItem item = dataItems.get(i);
					final long id = ContentUris.parseId(item.getUri());
					final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
					final UartConfiguration configuration = new UartConfiguration(dataMap, id);
					configurations.add(configuration);
				}
				mAdapter.setConfigurations(configurations);
				dataItems.release();
			}
		});
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:24,代码来源:UARTConfigurationsActivity.java

示例3: 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

示例4: 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::unlockAchievement" );
	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.unlockImmediate( helper.getClient(), achievementId );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

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

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

示例5: 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

示例6: 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::loadAchievements" );

	if( GameServicesHelper.getInstance().isAuthenticated() ) {
		PendingResult<Achievements.LoadAchievementsResult> result = Games.Achievements.load( GameServicesHelper.getInstance().getClient(), false );
		result.setResultCallback( this, 10, TimeUnit.SECONDS );
	} else {
		AIR.log( "User is not signed in." );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_ERROR, "User is not signed in." );
	}

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

示例7: 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

示例8: 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

示例9: onConnected

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
@Override
protected void onConnected() {
    PendingResult<Status> pendingResult = null;
    String actionStr = null;
    if (mAction == SUBSCRIBE) {
        pendingResult = Nearby.Messages.subscribe(
                getGoogleApiClient(), createNearbySubscribeIntent(), createSubscribeOptions());
        actionStr = "background subscribe";
    } else {
        pendingResult = Nearby.Messages.unsubscribe(
                getGoogleApiClient(), createNearbySubscribeIntent());
        actionStr = "background unsubscribe";
    }
    pendingResult.setResultCallback(new SimpleResultCallback(actionStr) {
        @Override
        public void onResult(final Status status) {
            super.onResult(status);
            disconnect();
            if (mCallback != null) {
                mCallback.run();
            }
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:NearbyBackgroundSubscription.java

示例10: callPlaceDetectionApi2

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
private void callPlaceDetectionApi2(final String ph_number) 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_individual(ph_number,placeLikelihood.getPlace().getAddress().toString());
                break;
            }
            likelyPlaces.release();
        }
    });
}
 
开发者ID:Pritom14,项目名称:Gps,代码行数:20,代码来源:Gps4Activity.java

示例11: onConnected

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    LocationRequest locationRequest = createLocationRequest();
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> locationSettingsResultPendingResult = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
    locationSettingsResultPendingResult
            .setResultCallback(new ResultCallback<LocationSettingsResult>() {
                @Override
                public void onResult(LocationSettingsResult result) {
                    if (LocationSettingsStatusCodes.SUCCESS != result.getStatus().getStatusCode()) {
                        if (result.getStatus().hasResolution()) {
                            handleLocationStatusResult(result.getStatus());
                        } else {
                            // TODO: faire quelque chose
                        }
                    }
                }
            });
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // la demande des droits est faite ailleurs
        return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
    onLocationChanged(LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient));
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:26,代码来源:MainActivity.java

示例12: configureLocationConnection

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
private void configureLocationConnection() {
    LocationRequest locationRequest = createLocationRequest();
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> locationSettingsResultPendingResult = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
    locationSettingsResultPendingResult
            .setResultCallback(new ResultCallback<LocationSettingsResult>() {
                @Override
                public void onResult(LocationSettingsResult result) {
                    if (LocationSettingsStatusCodes.SUCCESS != result.getStatus().getStatusCode()) {
                        Intent localIntent = new Intent(Constants.GOOGLE_API).putExtra(Constants.GOOGLE_API_LOCATION_RESULT, result.getStatus());
                        LocalBroadcastManager.getInstance(ParcoursService.this).sendBroadcast(localIntent);
                    }
                }
            });
    // noinspection MissingPermission : permissions dans le manifest
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:18,代码来源:ParcoursService.java

示例13: setupLocationPendingResult

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
protected final <T extends Result> void setupLocationPendingResult(PendingResult<T> pendingResult, ResultCallback<T> resultCallback) {
    if (timeoutTime != null && timeoutUnit != null) {
        pendingResult.setResultCallback(resultCallback, timeoutTime, timeoutUnit);
    } else {
        pendingResult.setResultCallback(resultCallback);
    }
}
 
开发者ID:florent37,项目名称:RxGps,代码行数:8,代码来源:RxLocationBaseOnSubscribe.java

示例14: onItemClick

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  UIUtils.hideKeyboard(AutoCompleteLocation.this.getContext(), AutoCompleteLocation.this);
  final AutocompletePrediction item = mAutoCompleteAdapter.getItem(position);
  if (item != null) {
    final String placeId = item.getPlaceId();
    PendingResult<PlaceBuffer> placeResult =
        Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId);
    placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
  }
}
 
开发者ID:jotaramirez90,项目名称:AutocompleteLocation,代码行数:11,代码来源:AutoCompleteLocation.java

示例15: onConnected

import com.google.android.gms.common.api.PendingResult; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
    Activity activity = getActivity("onConnected()");
    if (activity == null) {
        return;
    }

    LOGD(TAG, "Helper connected, account " + mAccountName);

    // load user's Google+ profile, if we don't have it yet
    if (!AccountUtils.hasPlusInfo(activity, mAccountName)) {
        LOGD(TAG, "We don't have Google+ info for " + mAccountName + " yet, so loading.");
        PendingResult<People.LoadPeopleResult> result = Plus.PeopleApi.load(mGoogleApiClient, "me");
        result.setResultCallback(this);
    } else {
        LOGD(TAG, "No need for Google+ info, we already have it.");
    }

    // try to authenticate, if we don't have a token yet
    if (!AccountUtils.hasToken(activity, mAccountName)) {
        LOGD(TAG, "We don't have auth token for " + mAccountName + " yet, so getting it.");
        mTokenTask = new GetTokenTask();
        mTokenTask.execute();
    } else {
        LOGD(TAG, "No need for auth token, we already have it.");
        reportAuthSuccess(false);
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:29,代码来源:LoginAndAuthHelper.java


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