本文整理汇总了Java中com.google.android.gms.common.api.ResultCallback类的典型用法代码示例。如果您正苦于以下问题:Java ResultCallback类的具体用法?Java ResultCallback怎么用?Java ResultCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResultCallback类属于com.google.android.gms.common.api包,在下文中一共展示了ResultCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGoogleApiClientReady
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
protected void onGoogleApiClientReady(final GoogleApiClient apiClient, final Observer<? super Status> observer) {
// this throws SecurityException if permissions are bad or mock locations are not enabled,
// which is passed to observer's onError by BaseObservable
LocationServices.FusedLocationApi.setMockMode(apiClient, true)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
startLocationMocking(apiClient, observer);
} else {
observer.onError(new StatusException(status));
}
}
});
}
示例2: onGoogleApiClientReady
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, final Observer<? super Status> observer) {
LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, locationRequest, intent)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (!status.isSuccess()) {
observer.onError(new StatusException(status));
} else {
observer.onNext(status);
observer.onCompleted();
}
}
});
}
示例3: call
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
public void call(final Subscriber<? super T> subscriber) {
result.setResultCallback(new ResultCallback<T>() {
@Override
public void onResult(T t) {
subscriber.onNext(t);
complete = true;
subscriber.onCompleted();
}
});
subscriber.add(Subscriptions.create(new Action0() {
@Override
public void call() {
if (!complete) {
result.cancel();
}
}
}));
}
示例4: play
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
/**
* Resumes the playback from where it was left (can be the beginning).
*
* @param customData Optional {@link JSONObject} data to be passed to the cast device
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void play(JSONObject customData) throws
TransientNetworkDisconnectionException, NoConnectionException {
LOGD(TAG, "play(customData)");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to play a video with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.play(mApiClient, customData)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_to_play,
result.getStatus().getStatusCode());
}
}
});
}
示例5: refreshPlacesData
import com.google.android.gms.common.api.ResultCallback; //导入依赖的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();
}
});
}
示例6: onResult
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
public void onResult(@NonNull DriveApi.DriveContentsResult driveContentsResult) {
OutputStream outputStream = driveContentsResult.getDriveContents().getOutputStream();
try {
outputStream.write("".getBytes());
driveContentsResult.getDriveContents().commit(mGoogleApiClient, null).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (!status.isSuccess())
Toast.makeText(getApplicationContext(), getString(R.string.drive_fail_save_data), Toast.LENGTH_LONG).show();
}
});
} catch (IOException e) {
Toast.makeText(getApplicationContext(), getString(R.string.drive_fail_save_data), Toast.LENGTH_LONG).show();
}
}
示例7: signOut
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
public void signOut() {
// Firebase sign out
mAuth.signOut();
// Google sign out
if (mGoogleApiClient.isConnected()) {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
// update user details.
}
});
}
}
示例8: setTextTrackStyle
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
/**
* Sets or updates the style of the Text Track.
*/
public void setTextTrackStyle(TextTrackStyle style) {
mRemoteMediaPlayer.setTextTrackStyle(mApiClient, style)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_to_set_track_style,
result.getStatus().getStatusCode());
}
}
});
for (VideoCastConsumer consumer : mVideoConsumers) {
try {
consumer.onTextTrackStyleChanged(style);
} catch (Exception e) {
LOGE(TAG, "onTextTrackStyleChanged(): Failed to inform " + consumer, e);
}
}
}
示例9: signOut
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
protected void signOut(GoogleApiClient googleApiClient){
mAuth.signOut();
Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
Toast toast = Toast.makeText(AuthBaseActivity.this,
mResources.getString(R.string.sign_out_text),
Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 100);
toast.show();
Intent i = new Intent(AuthBaseActivity.this, SignInActivity.class);
AuthBaseActivity.this.startActivity(i);
AuthBaseActivity.this.finish();
}
});
}
示例10: startMatch
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
public void startMatch(TurnBasedMatch match) {
System.out.println("Started match");
mTurnData = new GameModelWrapper();
mMatch = match;
String playerId = Games.Players.getCurrentPlayerId(gameHelper.getApiClient());
String myParticipantId = mMatch.getParticipantId(playerId);
Games.TurnBasedMultiplayer.takeTurn(gameHelper.getApiClient(), match.getMatchId(),
mTurnData.convertToByteArray(), myParticipantId).setResultCallback(
new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
@Override
public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
processResult(result);
}
});
}
示例11: setActiveTrackIds
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
/**
* Sets the active tracks for the currently loaded media.
*/
public void setActiveTrackIds(long[] trackIds) {
if (mRemoteMediaPlayer == null || mRemoteMediaPlayer.getMediaInfo() == null) {
return;
}
mRemoteMediaPlayer.setActiveMediaTracks(mApiClient, trackIds)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult mediaChannelResult) {
LOGD(TAG, "Setting track result was successful? "
+ mediaChannelResult.getStatus().isSuccess());
if (!mediaChannelResult.getStatus().isSuccess()) {
LOGD(TAG, "Failed since: " + mediaChannelResult.getStatus()
+ " and status code:" + mediaChannelResult.getStatus()
.getStatusCode());
}
}
});
}
示例12: callPlaceDetectionApi
import com.google.android.gms.common.api.ResultCallback; //导入依赖的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();
}
});
}
示例13: callPlaceDetectionApi
import com.google.android.gms.common.api.ResultCallback; //导入依赖的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();
}
});
}
示例14: startGeofenceMonitoring
import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
public void startGeofenceMonitoring() {
if (googleApiClient.isConnected()) {
for (com.team_htbr.a1617proj1bloeddonatie_app.Location location: locationsList) {
geofences.add(new Geofence.Builder()
.setRequestId(location.getName())
.setCircularRegion(location.getLat(), location.getLng(), 1000)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.setNotificationResponsiveness(5000)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER)
.build());
}
GeofencingRequest geofencingRequest = new GeofencingRequest.Builder()
.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER)
.addGeofences(geofences).build();
Intent intent = new Intent(this, GeofenceService.class);
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
if (!googleApiClient.isConnected()) {
Log.d(TAG, "no connection");
} else {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
LocationServices.GeofencingApi.addGeofences(googleApiClient, geofencingRequest, pendingIntent)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.d(TAG, "succesful add");
} else {
Log.d(TAG, "Failed to add");
}
}
});
}
}
}
示例15: findAllWearDevices
import com.google.android.gms.common.api.ResultCallback; //导入依赖的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());
}
}
});
}