本文整理汇总了Java中com.google.android.gms.common.api.Status.isSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java Status.isSuccess方法的具体用法?Java Status.isSuccess怎么用?Java Status.isSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.common.api.Status
的用法示例。
在下文中一共展示了Status.isSuccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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()) {
if (callback != null) callback.onSuggestFail(status);
autocompletePredictions.release();
return null;
}
return DataBufferUtils.freezeAndClose(autocompletePredictions);
}
return null;
}
示例4: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
if (mState != STATE_LAUNCHING_APPLICATION
&& mState != STATE_API_CONNECTION_SUSPENDED) {
throwInvalidState();
}
Status status = result.getStatus();
if (!status.isSuccess()) {
Log.e(TAG, "Launch application failed with status: %s, %d, %s",
mSource.getApplicationId(), status.getStatusCode(), status.getStatusMessage());
reportError();
}
mState = STATE_LAUNCH_SUCCEEDED;
reportSuccess(result);
}
示例5: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
// Update state and save in shared preferences.
mGeofencesAdded = !mGeofencesAdded;
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(Constants.GEOFENCES_ADDED_KEY, mGeofencesAdded);
editor.apply();
// Update the UI. Adding geofences enables the Remove Geofences button, and removing
// geofences enables the Add Geofences button.
// TODO: Update UI to inform that geofences have been added
Toast.makeText(
context,
context.getString(mGeofencesAdded ? R.string.geofences_added :
R.string.geofences_removed),
Toast.LENGTH_SHORT
).show();
} else {
// Get the status code for the error and log it using a user-friendly message.
String errorMessage = GeofenceErrorMessages.getErrorString(context,
status.getStatusCode());
Log.e(TAG, errorMessage);
}
}
示例6: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@Override
public void onResult(final Status status) {
if (status.isSuccess()) {
Log.d(TAG, "Nearby " + mAction + " succeeded");
} else {
Log.d(TAG, "Nearby " + mAction + " failed: " + status.getStatusMessage());
}
}
示例7: getPredictions
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
private ArrayList<PlaceAutocomplete> getPredictions(CharSequence constraint) {
if (mGoogleApiClient != null) {
Log.i(TAG, "Executing autocomplete query for: " + constraint);
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mPlaceFilter);
// Wait for predictions, set the timeout.
AutocompletePredictionBuffer autocompletePredictions = results
.await(60, TimeUnit.SECONDS);
final Status status = autocompletePredictions.getStatus();
if (!status.isSuccess()) {
Toast.makeText(getContext(), "We recommend using internet for better accuracy of the location! ", Toast.LENGTH_SHORT).show();
Log.e(TAG, "Error getting place predictions: " + status.toString());
autocompletePredictions.release();
return null;
}
Log.i(TAG, "Query completed. Received " + autocompletePredictions.getCount()
+ " predictions.");
Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();
ArrayList resultList = new ArrayList<>(autocompletePredictions.getCount());
while (iterator.hasNext()) {
AutocompletePrediction prediction = iterator.next();
resultList.add(new PlaceAutocomplete(prediction.getPlaceId(),
prediction.getFullText(null)));
}
// Buffer release
autocompletePredictions.release();
return resultList;
}
Log.e(TAG, "Google API client is not connected.");
return null;
}
示例8: handleStartDiscoveryResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
private void handleStartDiscoveryResult(Status status) {
if (status.isSuccess()) {
Timber.d("Discovering...");
updateConnectionStatus(CONNECTING, R.string.connection_info_discovering);
} else {
Timber.d("Discovery failed: " + status.getStatusMessage() + "(" + status.getStatusCode() + ")");
updateConnectionStatus(DISCONNECTED, R.string.connection_info_discovery_failed,
status.getStatusCode(),
status.getStatusMessage());
}
}
示例9: handleEndpointConnectionResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
private void handleEndpointConnectionResult(Status status) {
if (status.isSuccess()) {
// We successfully requested a connection. Now both sides
// must accept before the connection is established.
} else {
// Nearby Connections failed to request the connection.
}
Timber.d("onEndpointRequestConnection status: %s:%s ", status.getStatusCode(), status.getStatusMessage());
}
示例10: getAutoComplete
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
/**
* Method to call API for each user input
* @param constraint User input character string
* @return ArrayList containing suggestion results
*/
private ArrayList<PlaceAutoComplete> getAutoComplete(CharSequence constraint){
if(mGoogleApiClient.isConnected()){
//Making a query and fetching result in a pendingResult
PendingResult<AutocompletePredictionBuffer> results= Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient,constraint.toString(),mBounds,mPlaceFilter);
//Block and wait for 60s for a result
AutocompletePredictionBuffer autocompletePredictions=results.await(60, TimeUnit.SECONDS);
final Status status=autocompletePredictions.getStatus();
// Confirm that the query completed successfully, otherwise return null
if(!status.isSuccess()){
Log.e(TAG, "Error getting autocomplete prediction API call: " + status.toString());
autocompletePredictions.release();
return null;
}
Log.i(TAG, "Query completed. Received " + autocompletePredictions.getCount()
+ " predictions.");
// Copy the results into our own data structure, because we can't hold onto the buffer.
// AutocompletePrediction objects encapsulate the API response (place ID and description).
Iterator<AutocompletePrediction> iterator=autocompletePredictions.iterator();
ArrayList resultList=new ArrayList<>(autocompletePredictions.getCount());
while(iterator.hasNext()){
AutocompletePrediction prediction=iterator.next();
resultList.add(new PlaceAutoComplete(prediction.getPlaceId(),prediction.getPrimaryText(null),prediction.getSecondaryText(null)));
}
autocompletePredictions.release();
return resultList;
}else{
Log.e(TAG,"GoogleApiClient Not Connected");
return null;
}
}
示例11: RxStatus
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
public RxStatus(Status status) {
this.statusCode = status.getStatusCode();
this.message = status.getStatusMessage();
this.success = status.isSuccess();
}
示例12: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
/**
* Runs when the result of calling addGeofences() and removeGeofences() becomes available.
* Either method can complete successfully or with an error.
* <p>
* Since this activity implements the {@link ResultCallback} interface, we are required to
* define this method.
*
* @param status The Status returned through a PendingIntent when addGeofences() or
* removeGeofences() get called.
*/
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.e(TAG, "Geofence operation successful");
} else {
Log.e(TAG, "onResult Failure");
// Get the status code for the error and log it using a user-friendly message.
String errorMessage = GeofenceErrorMessages.getErrorString(getReactApplicationContext(),
status.getStatusCode());
Log.e(TAG, errorMessage);
}
}
示例13: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@Override
public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
// Check if the status code is not success.
Status status = result.getStatus();
if (!status.isSuccess()) {
Log.d("##MACHINITIATEDCALLBACK","errore!");
return;
}
TurnBasedMatch match = result.getMatch();
// If this player is not the first player in this match, continue.
if (match.getData() != null) {
Log.d("##MACHINITIATEDCALLBACK","WAITING FOR MY TURN");
return;
}
// Otherwise, this is the first player. Initialize the game state.
Log.d("##MACHINITIATEDCALLBACK","GAME STARTED");
//initGame(match);
// Let the player take the first turn
Log.d("##MACHINITIATEDCALLBACK","showTurnUi");
//showTurnUI(match);
}
示例14: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@Override
public void onResult(@NonNull Status status) {
if (!status.isSuccess()) {
emitter.onError(new StatusException(status));
}
}
示例15: getAutocomplete
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
/**
* Submits an autocomplete query to the Places Geo Data Autocomplete API.
* <p/>
* objects to store the Place ID and description that the API returns.
* Returns an empty list if no results were found.
* Returns null if the API client is not available or the query did not complete
* successfully.
* This method MUST be called off the main UI thread, as it will block until data is returned
* from the API, which may include a network request.
*
* @param constraint Autocomplete query string
* @return Results from the autocomplete API or null if the query was not successful.
* @see Places#GEO_DATA_API#getAutocomplete(CharSequence)
*/
private ArrayList<PlaceAutocomplete> getAutocomplete(CharSequence constraint) {
if (mGoogleApiClient.isConnected()) {
Log.i(TAG, "Starting autocomplete query for: " + constraint);
// Submit the query to the autocomplete API and retrieve a PendingResult that will
// contain the results when the query completes.
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mPlaceFilter);
// This method should have been called off the main UI thread. Block and wait for at most 60s
// for a result from the API.
AutocompletePredictionBuffer autocompletePredictions = results
.await(60, TimeUnit.SECONDS);
// Confirm that the query completed successfully, otherwise return null
final Status status = autocompletePredictions.getStatus();
if (!status.isSuccess()) {
Toast.makeText(getContext(), "Please check your internet connection", Toast.LENGTH_SHORT).show();
Log.e(TAG, "Error getting autocomplete prediction API call: " + status.getStatusMessage()+status.getStatus().getStatusMessage());
autocompletePredictions.release();
return null;
}
Log.i(TAG, "Query completed. Received " + autocompletePredictions.getCount()
+ " predictions.");
// Copy the results into our own data structure, because we can't hold onto the buffer.
// AutocompletePrediction objects encapsulate the API response (place ID and description).
Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();
ArrayList resultList = new ArrayList<>(autocompletePredictions.getCount());
while (iterator.hasNext()) {
AutocompletePrediction prediction = iterator.next();
// Get the details of this prediction and copy it into a new PlaceAutocomplete object.
resultList.add(new PlaceAutocomplete(prediction.getPlaceId(),
prediction.getFullText(null)));
}
// Release the buffer now that all data has been copied.
autocompletePredictions.release();
return resultList;
}
Log.e(TAG, "Google API client is not connected for autocomplete query.");
return null;
}