本文整理汇总了Java中com.google.android.gms.common.api.Status类的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Status类属于com.google.android.gms.common.api包,在下文中一共展示了Status类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleLocationStatusResult
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
private void handleLocationStatusResult(@NonNull Status status) {
if (mResolvingError) {
// Already attempting to resolve an error.
return;
}
if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
try {
status.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
// TODO: mieux gérer mResolvingError (attendre la résolution)
mResolvingError = true;
} catch (IntentSender.SendIntentException e) {
// There was an error with the resolution intent. Try again.
// TODO: mieux notifier le service
// mGoogleApiClient.connect();
MainActivity.this.startService(mCollecteServiceIntent);
mResolvingError = false;
}
} else {
// TODO: couper l'application ?
mResolvingError = true;
showErrorDialog(status.getStatusCode());
}
}
示例2: onActivityResult
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place pl = PlaceAutocomplete.getPlace(this, data);
location.setText(pl.getName());
currentTrip.setLocation(pl.getName().toString());
currentTrip.setLat(pl.getLatLng().latitude);
currentTrip.setLng(pl.getLatLng().longitude);
currentTrip.setPlaceId(pl.getId());
Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status stat = PlaceAutocomplete.getStatus(this, data);
Log.d(TAG, "onActivityResult: ");
}
else if (requestCode == RESULT_CANCELED){
System.out.println("Cancelled by the user");
}
}
else
super.onActivityResult(requestCode, resultCode, data);
}
示例3: onGoogleApiClientReady
import com.google.android.gms.common.api.Status; //导入依赖的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();
}
}
});
}
示例4: setMockMode
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
private void setMockMode(boolean toggle) {
if (toggle) {
mockLocationSubscription =
Observable.zip(locationProvider.mockLocation(mockLocationObservable),
mockLocationObservable, new Func2<Status, Location, String>() {
int count = 0;
@Override
public String call(Status result, Location location) {
return new LocationToStringFunc().call(location) + " " + count++;
}
})
.subscribe(new DisplayTextOnViewAction(mockLocationView), new ErrorHandler());
} else {
mockLocationSubscription.unsubscribe();
}
}
示例5: addGeofence
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
private void addGeofence() {
final GeofencingRequest geofencingRequest = createGeofencingRequest();
if (geofencingRequest == null) return;
final PendingIntent pendingIntent = createNotificationBroadcastPendingIntent();
reactiveLocationProvider
.removeGeofences(pendingIntent)
.flatMap(new Func1<Status, Observable<Status>>() {
@Override
public Observable<Status> call(Status pendingIntentRemoveGeofenceResult) {
return reactiveLocationProvider.addGeofences(pendingIntent, geofencingRequest);
}
})
.subscribe(new Action1<Status>() {
@Override
public void call(Status addGeofenceResult) {
toast("Geofence added, success: " + addGeofenceResult.isSuccess());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
toast("Error adding geofence.");
Log.d(TAG, "Error adding geofence.", throwable);
}
});
}
示例6: await
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
@NonNull
@Override
public Result await() {
if (!canceled && latch != null) {
try {
latch.await();
} catch (InterruptedException e) {
return new Result() {
@Override
public Status getStatus() {
return Canceled;
}
};
}
}
return new Result() {
@Override
public Status getStatus() {
return canceled ? Canceled : Success;
}
};
}
示例7: nearbySubscribe
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
private void nearbySubscribe() {
SubscribeOptions options = new SubscribeOptions.Builder()
.setStrategy(PUB_SUB_STRATEGY)
.setCallback(new SubscribeCallback() {
@Override
public void onExpired() {
super.onExpired();
Log.i(TAG, "No longer subscribing");
}
}).build();
Log.i(TAG, "Subscribing.");
Nearby.Messages.subscribe(mGoogleApiClient, mMessageListener, options)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "Subscribed successfully.");
emitSubscription("subscribe.onResult", "Subscribed successfully.");
} else {
Log.i(TAG, "Could not subscribe, status = " + status);
emitSubscription("subscribe.onResultErr", "Could not subscribe, status = " + status);
}
}
});
}
示例8: registerFence
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
protected void registerFence(final String fenceKey, final AwarenessFence fence) {
Awareness.FenceApi.updateFences(
client,
new FenceUpdateRequest.Builder()
.addFence(fenceKey, fence, myPendingIntent) //Add fence to the pendingIntent
.build())
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.e(fenceKey, "Fence was successfully registered.");
} else {
Log.e(fenceKey, "Fence could not be registered: " + status);
}
}
});
}
示例9: unregisterFence
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
protected void unregisterFence(final String fenceKey) {
Awareness.FenceApi.updateFences(
client,
new FenceUpdateRequest.Builder()
.removeFence(fenceKey)
.build()).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.e("Fence", "Fence " + fenceKey + " successfully removed.");
} else {
Log.e("Fence", "Fence " + fenceKey + " can not be removed.");
}
}
});
}
示例10: getAutocomplete
import com.google.android.gms.common.api.Status; //导入依赖的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;
}
示例11: getAutocompleteResults
import com.google.android.gms.common.api.Status; //导入依赖的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();
}
}
});
}
示例12: await
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
@NonNull
@Override
public Result await(long l, @NonNull TimeUnit timeUnit) {
if (!canceled && latch != null) {
try {
latch.await(l, timeUnit);
} catch (InterruptedException e) {
return new Result() {
@Override
public Status getStatus() {
return Canceled;
}
};
}
}
return new Result() {
@Override
public Status getStatus() {
return canceled ? Canceled : Success;
}
};
}
示例13: signOut
import com.google.android.gms.common.api.Status; //导入依赖的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();
}
});
}
示例14: signOut
import com.google.android.gms.common.api.Status; //导入依赖的package包/类
/**
* Sign the user out
*/
private void signOut() {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback<Status>() {
/**
* Result of signout attempt
* @param status - the status of the signout
*/
@Override
public void onResult(@NonNull Status status) {
mAuth.signOut();
mController.resetDatabaseManager();
Intent resultIntent = new Intent();
setResult(RESULT_OK, resultIntent);
finish();
}
});
}
示例15: getAutocomplete
import com.google.android.gms.common.api.Status; //导入依赖的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;
}