當前位置: 首頁>>代碼示例>>Java>>正文


Java Status類代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:ANFR-France,項目名稱:proto-collecte,代碼行數:26,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:25,代碼來源:TripEditorActivity.java

示例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();
                    }
                }
            });

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:AddLocationIntentUpdatesObservable.java

示例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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:MockLocationsActivity.java

示例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);
                }
            });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:GeofenceActivity.java

示例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;
        }
    };
}
 
開發者ID:sarveshchavan7,項目名稱:Trivia-Knowledge,代碼行數:23,代碼來源:SnapshotCoordinator.java

示例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);
                    }
                }
            });
}
 
開發者ID:miguelespinoza,項目名稱:react-native-nearby,代碼行數:27,代碼來源:NearbyModule.java

示例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);
                    }
                }
            });
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:18,代碼來源:AwarenessMotionUpdatesProvider.java

示例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.");
            }
        }
    });
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:18,代碼來源:AwarenessMotionUpdatesProvider.java

示例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;
}
 
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:23,代碼來源:PlaceAutocompleteAdapter.java

示例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();
            }
        }
    });
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:31,代碼來源:DataManager.java

示例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;
        }
    };
}
 
開發者ID:jaysondc,項目名稱:TripleTap,代碼行數:23,代碼來源:SnapshotCoordinator.java

示例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();
        }
    });
}
 
開發者ID:AviralGarg1993,項目名稱:VR-One,代碼行數:19,代碼來源:AuthBaseActivity.java

示例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();
        }
    });
}
 
開發者ID:iskandergaba,項目名稱:Botanist,代碼行數:20,代碼來源:AccountActivity.java

示例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;
}
 
開發者ID:jotaramirez90,項目名稱:AutocompleteLocation,代碼行數:21,代碼來源:AutoCompleteAdapter.java


注:本文中的com.google.android.gms.common.api.Status類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。