Java 类com.google.android.gms.common.api.ResultCallback 实例源码
项目:GitHub
文件:MockLocationObservable.java
@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));
}
}
});
}
项目:GitHub
文件:AddLocationIntentUpdatesObservable.java
@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();
}
}
});
}
项目:GitHub
文件:PendingResultObservable.java
@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();
}
}
}));
}
项目:Pocket-Plays-for-Twitch
文件:VideoCastManager.java
/**
* 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());
}
}
});
}
项目:Shush
文件:MainActivity.java
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();
}
});
}
项目:Note
文件:MainActivity.java
@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();
}
}
项目:GodotFireBase
文件:GoogleSignIn.java
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.
}
});
}
}
项目:Pocket-Plays-for-Twitch
文件:VideoCastManager.java
/**
* 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);
}
}
}
项目:VR-One
文件:AuthBaseActivity.java
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();
}
});
}
项目:retro-reversi
文件:AndroidLauncher.java
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);
}
});
}
项目:Pocket-Plays-for-Twitch
文件:VideoCastManager.java
/**
* 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());
}
}
});
}
项目:Addy-Android
文件:PlacesAPIActivity.java
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();
}
});
}
项目:Gps
文件:Gps4Activity.java
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();
}
});
}
项目:Note
文件:MainActivity.java
@Override
public void onResult(@NonNull DriveApi.DriveContentsResult driveContentsResult) {
OutputStream outputStream = driveContentsResult.getDriveContents().getOutputStream();
try {
outputStream.write(DataManager.getAsJsonObject().toString().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();
} finally {
runOnUiThread(new Runnable() {
@Override
public void run() {
loadingView.setVisibility(View.GONE);
}
});
}
}
项目:1617PROJ1Bloeddonatie-app
文件:MainActivity.java
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");
}
}
});
}
}
}
项目:Excuser
文件:DeviceWearConnectionFragment.java
@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());
}
}
});
}
项目:Pocket-Plays-for-Twitch
文件:VideoCastManager.java
/**
* Removes the item with {@code itemId} from the queue.
* <p>
* If {@code itemId} is not found in the queue, this method will silently return without sending
* a request to the receiver. A {@code itemId} may not be in the queue because it wasn't
* originally in the queue, or it was removed by another sender.
*
* @param itemId The ID of the item to be removed.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
* @throws IllegalArgumentException
*/
public void queueRemoveItem(final int itemId, final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException,
IllegalArgumentException {
LOGD(TAG, "queueRemoveItem");
checkConnectivity();
if (itemId == MediaQueueItem.INVALID_ITEM_ID) {
throw new IllegalArgumentException("itemId is invalid");
}
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to remove an item from queue with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer
.queueRemoveItem(mApiClient, itemId, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_REMOVE_ITEM,
result.getStatus().getStatusCode());
}
}
});
}
项目:godot-google-play-game-services
文件:GodotPlayGameServices.java
/**
* Submit a given score to the specified leaderboard immediately
* with a callback result
* @param id leaderboard id obtained from your Developer Console
* @param score score number the player earned
*
* Usage:
* const ST_OK = "STATUS_OK"
* var leaderboard_id = "exampleLeaderbord123ID"
*
* ...
*
* gpgs.leaderboard_submit_score_immediate(leaderboard_id, 9001)
*
* ...
*
* func _on_leaderboard_score_submitted(id, score, status):
* if status == ST_OK:
* //succeeded action
* else:
* //failed action
*/
public void leaderboard_submit_score_immediate(final String id, final int score) {
logMethod();
if (!isConnectedLogged()) return;
final boolean debug = this.debug;
leaderboards.submitScoreImmediate(
id, score, new ResultCallback<Leaderboards.SubmitScoreResult>() {
@Override
public void onResult(@NonNull Leaderboards.SubmitScoreResult submitScoreResult) {
String status = extractStatusNameFromStatus(
submitScoreResult.getStatus().toString());
if (debug) Log.d(TAG, MODULE
+ ": > tried to submit score value " + String.valueOf(score)
+ " with " + status);
GodotLib.calldeferred(
instance_id, "_on_leaderboard_score_submitted",
new Object[] { id, score, status });
}
});
}
项目:godot-google-play-game-services
文件:GodotPlayGameServices.java
/**
* Unlock an achievement with a given id immediately
* with a callback result
*
* @param achievement_id achievement id obtained from your Developer Console
*
* Usage:
* const ST_OK = "STATUS_OK"
* var achievement_toasty = "achievemnt123ID"
*
* ...
*
* gpgs.achievement_unlock_immediate(achievement_toasty)
*
*
* ...
*
* func _on_achievement_unlocked(id, status):
* if status == ST_OK:
* //succeeded action
* else:
* //failed action
*/
public void achievement_unlock_immediate(final String achievement_id) {
logMethod();
if(!isConnectedLogged()) return;
achievements.unlockImmediate(
achievement_id,
new ResultCallback<Achievements.UpdateAchievementResult>() {
@Override
public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
String status = extractStatusNameFromStatus(
updateAchievementResult.getStatus().toString());
Log.d(TAG, MODULE
+ ": > tried to unlock achievement " + achievement_id
+ " with " + status);
GodotLib.calldeferred(
instance_id, "_on_achievement_unlocked",
new Object[] { achievement_id, status });
}
});
}
项目:godot-google-play-game-services
文件:GodotPlayGameServices.java
/**
* Increment an achievement with a given id by a given amount of points immediately
* with a callback result
*
* @param achievement_id achievement id obtained from your Developer Console
* @param increment_amount ammount of points to increment the achievement by
*
* Usage:
* const ST_OK = "STATUS_OK"
* var achievement_toasty = "achievemnt123ID"
*
* ...
*
* gpgs.achievement_reveal_immediate(achievement_toasty)
*
* ....
*
* func _on_achievement_revealed(id, increment_amount, status):
* if status == ST_OK:
* //succeeded action
* else:
* //failed action
*/
public void achievement_increment_immediate(final String achievement_id, final int increment_amount) {
logMethod();
if(!isConnectedLogged()) return;
achievements.incrementImmediate(
achievement_id, increment_amount,
new ResultCallback<Achievements.UpdateAchievementResult>() {
@Override
public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
String status = extractStatusNameFromStatus(
updateAchievementResult.getStatus().toString());
Log.d(TAG, MODULE
+ ": > tried to increment achievement " + achievement_id
+" by " + String.valueOf(increment_amount)
+ " with " + status);
GodotLib.calldeferred(
instance_id, "_on_achievement_incremented",
new Object[] { achievement_id, increment_amount, status });
}
});
}
项目:GeoFencer
文件:PlayGeofenceProvider.java
private void startInternal(final Location homeLocation, PendingIntent pendingIntent) {
GeofencingRequest geofenceRequest = createGeofenceRequest(homeLocation);
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
ToastLog.logShort(context, TAG, "Starting Play geofencing...");
LocationServices.GeofencingApi.addGeofences(
googleApiClient,
geofenceRequest,
pendingIntent
).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.getStatusMessage() != null) {
ToastLog.warnShort(context, TAG, status.getStatusMessage());
}
}
});
}
}
项目:android-things-distributed-piano
文件:PianoPresenter.java
@Override
public void onConnectionRequest(final String endpointId, String deviceId, String endpointName, byte[] payload) {
Log.d(TAG, "onConnectionRequest");
Nearby.Connections.acceptConnectionRequest(googleApiClient, endpointId, payload, this)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.d(TAG, "acceptConnectionRequest: SUCCESS");
} else {
Log.d(TAG, "acceptConnectionRequest: FAILURE");
}
}
});
}
项目:Stalker
文件:PlaceFragment.java
void getCurrentPlace() throws SecurityException {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(placeApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (int i = 0; i < likelyPlaces.getCount() && i < 5; i++) {
PlaceEntry place = new PlaceEntry();
if (likelyPlaces.get(i).getLikelihood() == 0) continue;
place.setName(likelyPlaces.get(i).getPlace().getName().toString());
place.setLatLon(likelyPlaces.get(i).getPlace().getLatLng());
myDataset.add(place);
mAdapter.notifyItemInserted(myDataset.size() - 1);
}
getMapA();
likelyPlaces.release();
}
});
}
项目:Excuser
文件:MainWearActivity.java
private void checkIfPhoneHasApp() {
Log.d(TAG, "checkIfPhoneHasApp()");
PendingResult<CapabilityApi.GetCapabilityResult> pendingResult =
Wearable.CapabilityApi.getCapability(
mGoogleApiClient,
CAPABILITY_PHONE_APP,
CapabilityApi.FILTER_ALL);
pendingResult.setResultCallback(new ResultCallback<CapabilityApi.GetCapabilityResult>() {
@Override
public void onResult(@NonNull CapabilityApi.GetCapabilityResult getCapabilityResult) {
Log.d(TAG, "onResult(): " + getCapabilityResult);
if (getCapabilityResult.getStatus().isSuccess()) {
CapabilityInfo capabilityInfo = getCapabilityResult.getCapability();
mAndroidPhoneNodeWithApp = pickBestNodeId(capabilityInfo.getNodes());
verifyNodeAndUpdateUI();
} else {
Log.d(TAG, "Failed CapabilityApi: " + getCapabilityResult.getStatus());
}
}
});
}
项目:RxSocialAuth
文件:RxSmartLockPasswordsFragment.java
private void requestCredentialAndAutoSignIn() {
// disable auto sign in
if(mDisableAutoSignIn)
Auth.CredentialsApi.disableAutoSignIn(mCredentialsApiClient);
Auth.CredentialsApi.request(mCredentialsApiClient, mCredentialRequest).setResultCallback(
new ResultCallback<CredentialRequestResult>() {
@Override
public void onResult(@NonNull CredentialRequestResult credentialRequestResult) {
if(credentialRequestResult.getStatus().isSuccess())
onCredentialRetrieved(credentialRequestResult.getCredential());
else
resolveResult(credentialRequestResult.getStatus());
}
});
}
项目:Remindy
文件:GeofenceUtil.java
public static void addGeofences(final Context context, GoogleApiClient googleApiClient) {
checkGoogleApiClient(googleApiClient);
List<Place> places = new RemindyDAO(context).getActivePlaces();
if(places.size() > 0) {
if (PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)) {
LocationServices.GeofencingApi.addGeofences(
googleApiClient,
getGeofencingRequest(places),
getGeofencePendingIntent(context)
).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if(status.isSuccess())
Toast.makeText(context, "Geofences added/updated!", Toast.LENGTH_SHORT).show();
}
});
}
}
}
项目:Pocket-Plays-for-Twitch
文件:VideoCastManager.java
/**
* Seeks to the given point without changing the state of the player, i.e. after seek is
* completed, it resumes what it was doing before the start of seek.
*
* @param position in milliseconds
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void seek(int position) throws TransientNetworkDisconnectionException,
NoConnectionException {
LOGD(TAG, "attempting to seek media");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to seek a video with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.seek(mApiClient,
position,
RemoteMediaPlayer.RESUME_STATE_UNCHANGED).
setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_seek, result.getStatus().getStatusCode());
}
}
});
}
项目:Note
文件:MainActivity.java
@Override
public void onResult(@NonNull final DriveApi.DriveContentsResult driveContentsResult) {
new Thread(new Runnable() {
@Override
public void run() {
DriveFolder appFolder = Drive.DriveApi.getAppFolder(mGoogleApiClient);
MetadataChangeSet set = new MetadataChangeSet.Builder().setTitle(getString(R.string.drive_file_name)).setMimeType(getString(R.string.drive_file_mimetype)).build();
appFolder.createFile(mGoogleApiClient, set, driveContentsResult.getDriveContents()).setResultCallback(new ResultCallback<DriveFolder.DriveFileResult>() {
@Override
public void onResult(@NonNull DriveFolder.DriveFileResult driveFileResult) {
driveFileResult.getDriveFile().open(mGoogleApiClient, DriveFile.MODE_WRITE_ONLY, null).setResultCallback(writeDriveCallback);
loadingView.setVisibility(View.GONE);
}
});
}
}).start();
}
项目:proto-collecte
文件:MainActivity.java
@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));
}
项目:Pocket-Plays-for-Twitch
文件:VideoCastManager.java
/**
* Pauses the playback.
*
* @param customData Optional {@link JSONObject} data to be passed to the cast device
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void pause(JSONObject customData) throws
TransientNetworkDisconnectionException, NoConnectionException {
LOGD(TAG, "attempting to pause media");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to pause a video with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.pause(mApiClient, customData)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_to_pause,
result.getStatus().getStatusCode());
}
}
});
}
项目:AddyHINT17
文件:PlacesAPIActivity.java
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();
}
});
}
项目:BonAppetit_Android-Project
文件:MapsActivity.java
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
final String placeId=dataSnapshot.getKey();
if(placeId!=null)
{
Places.GeoDataApi
.getPlaceById(mGoogleApiClient,placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
LatLng location=places.get(0).getLatLng();
//CharSequence userName=places.get(1).getName();
//Toast.makeText(getApplicationContext(),"reached onChildAdded",Toast.LENGTH_SHORT).show();
addPointToView(location);
mMap.addMarker(new MarkerOptions()
.position(location));
//Toast.makeText(getApplicationContext(),"place added",Toast.LENGTH_SHORT).show();
places.release();
}
});
}
}
项目:igrow-android
文件:SignInActivity.java
@Override
public void onStart() {
super.onStart();
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
// and the GoogleSignInResult will be available instantly.
Log.d(TAG, "Got cached sign-in");
GoogleSignInResult result = opr.get();
handleSignInResult(result);
} else {
// If the user has not previously signed in on this device or the sign-in has expired,
// this asynchronous branch will attempt to sign in the user silently. Cross-device
// single sign-on will occur in this branch.
showProgressDialog();
opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(GoogleSignInResult googleSignInResult) {
hideProgressDialog();
handleSignInResult(googleSignInResult);
}
});
}
}
项目:GitHub
文件:AddGeofenceObservable.java
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, final Observer<? super Status> observer) {
LocationServices.GeofencingApi.addGeofences(apiClient, request, geofenceTransitionPendingIntent)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
observer.onNext(status);
observer.onCompleted();
} else {
observer.onError(new StatusException(status));
}
}
});
}
项目:GitHub
文件:RemoveGeofenceByPendingIntentObservable.java
@Override
protected void removeGeofences(GoogleApiClient locationClient, final Observer<? super Status> observer) {
LocationServices.GeofencingApi.removeGeofences(locationClient, pendingIntent)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
observer.onNext(status);
observer.onCompleted();
} else {
observer.onError(new StatusException(status));
}
}
});
}
项目:GitHub
文件:MockLocationObservable.java
private void startLocationMocking(final GoogleApiClient apiClient, final Observer<? super Status> observer) {
mockLocationSubscription = locationObservable.subscribe(new Action1<Location>() {
@Override
public void call(Location location) {
LocationServices.FusedLocationApi.setMockLocation(apiClient, location)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
observer.onNext(status);
} else {
observer.onError(new StatusException(status));
}
}
});
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
observer.onError(throwable);
}
}, new Action0() {
@Override
public void call() {
observer.onCompleted();
}
});
}
项目:GitHub
文件:RemoveLocationIntentUpdatesObservable.java
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, final Observer<? super Status> observer) {
LocationServices.FusedLocationApi.removeLocationUpdates(apiClient, intent)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
observer.onNext(status);
observer.onCompleted();
} else {
observer.onError(new StatusException(status));
}
}
});
}
项目:Runnest
文件:RunFragment.java
private void stopLocationUpdates() {
LocationServices.FusedLocationApi.removeLocationUpdates(
googleApiClient,
this
).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status r) {
requestingLocationUpdates = false;
mapHandler.stopShowingLocation();
}
});
}
项目:hypertrack-live-android
文件:ActionManager.java
public void addGeofencingRequest() {
if (geofencingRequest == null) {
return;
}
if (this.mGoogleAPIClient == null || !this.mGoogleAPIClient.isConnected()) {
this.addGeofencingRequest = true;
setupGoogleAPIClient();
return;
}
try {
Intent geofencingIntent = new Intent(mContext, GeofenceTransitionsIntentService.class);
mGeofencePendingIntent = PendingIntent.getService(mContext, 0, geofencingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
LocationServices.GeofencingApi.addGeofences(mGoogleAPIClient, geofencingRequest, mGeofencePendingIntent).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
HyperLog.i(TAG, "Geofence set at Expected Place");
addGeofencingRequest = false;
} else {
HyperLog.e(TAG, "Geofence error at Expected Place" + status.getStatusMessage());
addGeofencingRequest = true;
}
}
});
} catch (SecurityException | IllegalArgumentException exception) {
HyperLog.e(TAG, "Geofence error at Expected Place" + exception.getMessage());
CrashlyticsWrapper.log(exception);
}
}
项目:GodotFireBase
文件:GoogleSignIn.java
public void revokeAccess () {
mAuth.signOut();
// Google sign out
Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
// update user details.
}
});
}