当前位置: 首页>>代码示例>>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;未经允许,请勿转载。