com.google.android.gms.common.api.ResultCallback Java Examples
The following examples show how to use
com.google.android.gms.common.api.ResultCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeofenceManager.java From android-sdk with MIT License | 6 votes |
private void removeGeofences(final Location location) { updating = true; try { LocationServices.GeofencingApi .removeGeofences( play.getClient(), GeofenceReceiver.getGeofencePendingIntent(context)) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { registerGeofences(location); } else { onGeofencesFailed(null, status.getStatusCode()); } } }); } catch (SecurityException | IllegalStateException ex) { onGeofencesFailed(ex, 0); } }
Example #2
Source File: SmartLock.java From easygoogle with Apache License 2.0 | 6 votes |
/** * Begin the process of retrieving a {@link Credential} for the device user. This can have * a few different results: * 1) If the user has auto sign-in enabled and exactly one previously saved credential, * {@link SmartLockListener#onCredentialRetrieved(Credential)} will be called and * you can sign the user in immediately. * 2) If the user has multiple saved credentials or one saved credential and has disabled * auto sign-in, you will get the callback {@link SmartLockListener#onShouldShowCredentialPicker()} * at which point you can choose to show the picker dialog to continue. * 3) If the user has no saved credentials or cancels the operation, you will receive the * {@link SmartLockListener#onCredentialRetrievalFailed()} callback. */ public void getCredentials() { CredentialRequest request = buildCredentialRequest(); Auth.CredentialsApi.request(getFragment().getGoogleApiClient(), request) .setResultCallback(new ResultCallback<CredentialRequestResult>() { @Override public void onResult(CredentialRequestResult result) { if (result.getStatus().isSuccess()) { // Single credential, auto sign-in Credential credential = result.getCredential(); getListener().onCredentialRetrieved(credential); } else if (result.getStatus().hasResolution() && result.getStatus().getStatusCode() != CommonStatusCodes.SIGN_IN_REQUIRED) { // Multiple credentials or auto-sign in disabled. If the status // code is SIGN_IN_REQUIRED then it is a hint credential, which we // do not want at this point. getListener().onShouldShowCredentialPicker(); } else { // Could not retrieve credentials getListener().onCredentialRetrievalFailed(); } } }); }
Example #3
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 6 votes |
private DataSet getDataSet() { ArrayList<Session> sessions = new ArrayList<>(); sessions.add(_mockSession); ArgumentCaptor<ResultCallback> captor = ArgumentCaptor.forClass(ResultCallback.class); verify(_mockResult, times(1)).setResultCallback(captor.capture()); ArgumentCaptor<Session> sessionArgumentCaptor = ArgumentCaptor.forClass(Session.class); captor.getValue().onResult(new SessionStopResult(new Status(1), sessions)); ArgumentCaptor<DataSet> dataSetArgumentCaptor = ArgumentCaptor.forClass(DataSet.class); verify(_mockPlayServices,times(1)).newSessionInsertRequest(sessionArgumentCaptor.capture(), dataSetArgumentCaptor.capture()); assertEquals(_mockSession, sessionArgumentCaptor.getValue()); return dataSetArgumentCaptor.getValue(); }
Example #4
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override public void run() { PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(COUNT_PATH); putDataMapRequest.getDataMap().putInt(COUNT_KEY, count++); PutDataRequest request = putDataMapRequest.asPutDataRequest(); LOGD(TAG, "Generating DataItem: " + request); if (!mGoogleApiClient.isConnected()) { return; } Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataItemResult>() { @Override public void onResult(DataItemResult dataItemResult) { if (!dataItemResult.getStatus().isSuccess()) { Log.e(TAG, "ERROR: failed to putDataItem, status code: " + dataItemResult.getStatus().getStatusCode()); } } }); }
Example #5
Source File: GoogleFit.java From OpenFit with MIT License | 6 votes |
public void disconnectGoogleFit() { if(mClient.isConnected()) { Log.d(LOG_TAG, "Disconnecting to GoogleFit"); PendingResult<Status> pendingResult = Fitness.ConfigApi.disableFit(mClient); pendingResult.setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { if(status.isSuccess()) { //GFIT_CONNECTED = false; Log.d(LOG_TAG, "Google Fit disabled"); Intent msg = new Intent(OpenFitIntent.INTENT_GOOGLE_FIT); msg.putExtra(OpenFitIntent.INTENT_EXTRA_MSG, OpenFitIntent.INTENT_GOOGLE_FIT); msg.putExtra(OpenFitIntent.INTENT_EXTRA_DATA, false); //getActivity().sendBroadcast(msg); mClient.disconnect(); } else { Log.e(LOG_TAG, "Google Fit wasn't disabled " + status); } } }); } }
Example #6
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void detectNearbyPlaces() { if( !checkLocationPermission() ) { return; } Awareness.SnapshotApi.getPlaces(mGoogleApiClient) .setResultCallback(new ResultCallback<PlacesResult>() { @Override public void onResult(@NonNull PlacesResult placesResult) { Place place; for( PlaceLikelihood placeLikelihood : placesResult.getPlaceLikelihoods() ) { place = placeLikelihood.getPlace(); Log.e("Tuts+", place.getName().toString() + "\n" + place.getAddress().toString() ); Log.e("Tuts+", "Rating: " + place.getRating() ); Log.e("Tuts+", "Likelihood that the user is here: " + placeLikelihood.getLikelihood() * 100 + "%"); } } }); }
Example #7
Source File: GoogleCloudSave.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
private void startResolving(final UserData userData, final Snapshot conflictingSnapshot, final String conflictId, final IConflictResolver resolver) { final SnapshotContents contents = conflictingSnapshot.getSnapshotContents(); final Map server = fromBytes(contents); if (server == null) { contents.writeBytes(toBytes(userData)); Games.Snapshots.resolveConflict(client, conflictId, SNAPSHOT_ID, EMPTY_CHANGE, contents); return; } performUserResolve(server, resolver, new IConflictResolverCallback() { @SuppressWarnings("unchecked") @Override public void onResolved(boolean useLocal) { contents.writeBytes(useLocal ? toBytes(userData) : toBytes(server)); Games.Snapshots .resolveConflict(client, conflictId, SNAPSHOT_ID, EMPTY_CHANGE, contents) .setResultCallback(new ResultCallback<OpenSnapshotResult>() { @Override public void onResult(OpenSnapshotResult result) { if (result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_SNAPSHOT_CONFLICT) { startResolving(userData, result.getConflictingSnapshot(), result.getConflictId(), resolver); } } }); } }); }
Example #8
Source File: GapiFenceManager.java From JCVD with MIT License | 6 votes |
/** * Ask to remove a fence from the Google API. * @param fenceId The id of the fence to remove. * @param status the status that will be called when the addition fails or succeed. * @return true if remove has been asked, false otherwise. */ boolean removeFence(@NonNull String fenceId, final ResultCallback<Status> status) { FenceUpdateRequest.Builder requestBuilder = new FenceUpdateRequest.Builder() .removeFence(fenceId); mFenceClient.updateFences(requestBuilder.build()).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { status.onResult(Status.RESULT_SUCCESS); } else { status.onResult(Status.RESULT_INTERNAL_ERROR); } } }); return true; }
Example #9
Source File: ListenerService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private void setLocalNodeName () { forceGoogleApiConnect(); PendingResult<NodeApi.GetLocalNodeResult> result = Wearable.NodeApi.getLocalNode(googleApiClient); result.setResultCallback(new ResultCallback<NodeApi.GetLocalNodeResult>() { @Override public void onResult(NodeApi.GetLocalNodeResult getLocalNodeResult) { if (!getLocalNodeResult.getStatus().isSuccess()) { Log.e(TAG, "ERROR: failed to getLocalNode Status=" + getLocalNodeResult.getStatus().getStatusMessage()); } else { Log.d(TAG, "getLocalNode Status=: " + getLocalNodeResult.getStatus().getStatusMessage()); Node getnode = getLocalNodeResult.getNode(); localnode = getnode != null ? getnode.getDisplayName() + "|" + getnode.getId() : ""; Log.d(TAG, "setLocalNodeName. localnode=" + localnode); } } }); }
Example #10
Source File: MapsActivity.java From io2015-codelabs with Apache License 2.0 | 6 votes |
/** * Act upon new check-outs when they appear. */ @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { String placeId = dataSnapshot.getKey(); if (placeId != null) { Places.GeoDataApi .getPlaceById(mGoogleApiClient, placeId) .setResultCallback(new ResultCallback<PlaceBuffer>() { @Override public void onResult(PlaceBuffer places) { LatLng location = places.get(0).getLatLng(); addPointToViewPort(location); mMap.addMarker(new MarkerOptions().position(location)); places.release(); } } ); } }
Example #11
Source File: MainActivity.java From WearOngoingNotificationSample with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void sendMessage() { if (mGoogleApiClient.isConnected()) { PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(Constants.PATH_NOTIFICATION); // Add data to the request putDataMapRequest.getDataMap().putString(Constants.KEY_TITLE, String.format("hello world! %d", count++)); Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Asset asset = createAssetFromBitmap(icon); putDataMapRequest.getDataMap().putAsset(Constants.KEY_IMAGE, asset); PutDataRequest request = putDataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { Log.d(TAG, "putDataItem status: " + dataItemResult.getStatus().toString()); } }); } }
Example #12
Source File: WatchServices.java From WearPay with GNU General Public License v2.0 | 6 votes |
@DebugLog private void sendToWatch(String code) { Bitmap bitmapQR = EncodingHandlerUtils.createQRCode(code, 600); Bitmap bitmapBar = EncodingHandlerUtils.createBarcode(code, 600, 200); PutDataMapRequest dataMap = PutDataMapRequest.create(Common.PATH_QR_CODE); dataMap.getDataMap().putAsset(Common.KEY_QR_CODE, toAsset(bitmapQR)); dataMap.getDataMap().putAsset(Common.KEY_BAR_CODE, toAsset(bitmapBar)); PutDataRequest request = dataMap.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override @DebugLog public void onResult(DataApi.DataItemResult dataItemResult) { if (dataItemResult.getStatus().isSuccess()) { System.out.println("发送成功"); } else { System.out.println("发送失败"); } } }); //sendMessageToAllNodes(Common.PATH_CODE, code.getBytes()); }
Example #13
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void findPlaceById( String id ) { if( TextUtils.isEmpty( id ) || mGoogleApiClient == null || !mGoogleApiClient.isConnected() ) return; Places.GeoDataApi.getPlaceById( mGoogleApiClient, id ) .setResultCallback( new ResultCallback<PlaceBuffer>() { @Override public void onResult(PlaceBuffer places) { if( places.getStatus().isSuccess() ) { Place place = places.get( 0 ); displayPlace( place ); mPredictTextView.setText( "" ); mAdapter.clear(); } //Release the PlaceBuffer to prevent a memory leak places.release(); } } ); }
Example #14
Source File: VideoCastManager.java From UTubeTV with The Unlicense | 6 votes |
/** * 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. * <p/> * position in milliseconds */ public void seek(int position) throws TransientNetworkDisconnectionException, NoConnectionException { CastUtils.LOGD(TAG, "attempting to seek media"); checkConnectivity(); if (mRemoteMediaPlayer == null) { CastUtils.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.failed_seek, result.getStatus().getStatusCode()); } } }); }
Example #15
Source File: DataCastManager.java From android with Apache License 2.0 | 6 votes |
/** * Sends the <code>message</code> on the data channel for the <code>namespace</code>. If fails, * it will call <code>onMessageSendFailed</code> * * @param message * @param namespace * @throws NoConnectionException If no connectivity to the device exists * @throws TransientNetworkDisconnectionException If framework is still trying to recover from a * possibly transient loss of network * @throws IllegalArgumentException If the the message is null, empty, or too long; or if the * namespace is null or too long. * @throws IllegalStateException If there is no active service connection. * @throws IOException */ public void sendDataMessage(String message, String namespace) throws IllegalArgumentException, IllegalStateException, IOException, TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); if (TextUtils.isEmpty(namespace)) { throw new IllegalArgumentException("namespace cannot be empty"); } Cast.CastApi.sendMessage(mApiClient, namespace, message). setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status result) { if (!result.isSuccess()) { DataCastManager.this.onMessageSendFailed(result); } } }); }
Example #16
Source File: SunsetsWatchFaceUtil.java From american-sunsets-watch-face with Apache License 2.0 | 6 votes |
/** * Asynchronously fetches the current config {@link DataMap} for {@link SunsetsWatchFace} * and passes it to the given callback. * <p> * If the current config {@link DataItem} doesn't exist, it isn't created and the callback * receives an empty DataMap. */ public static void fetchConfigDataMap(final GoogleApiClient client, final FetchConfigDataMapCallback callback) { Wearable.NodeApi.getLocalNode(client).setResultCallback( new ResultCallback<NodeApi.GetLocalNodeResult>() { @Override public void onResult(NodeApi.GetLocalNodeResult getLocalNodeResult) { String localNode = getLocalNodeResult.getNode().getId(); Uri uri = new Uri.Builder() .scheme("wear") .path(SunsetsWatchFaceUtil.PATH_WITH_FEATURE) .authority(localNode) .build(); Wearable.DataApi.getDataItem(client, uri) .setResultCallback(new DataItemResultCallback(callback)); } } ); }
Example #17
Source File: RobocarDiscoverer.java From robocar with Apache License 2.0 | 6 votes |
public void rejectConnection() { final RobocarConnection connection = mRobocarConnectionLiveData.getValue(); if (connection == null) { return; } connection.setState(ConnectionState.AUTH_REJECTED); rejectConnection(connection.getEndpointId()) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { Log.d(TAG, "Rejected connection."); } else { Log.d(TAG, String.format("Reject unsuccessful. %d %s", status.getStatusCode(), status.getStatusMessage())); connection.setState(ConnectionState.AUTHENTICATING); } } }); }
Example #18
Source File: RobocarDiscoverer.java From robocar with Apache License 2.0 | 6 votes |
public void acceptConnection() { final RobocarConnection connection = mRobocarConnectionLiveData.getValue(); if (connection == null) { return; } connection.setState(ConnectionState.AUTH_ACCEPTED); acceptConnection(connection.getEndpointId()) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { Log.d(TAG, "Accepted connection."); } else { Log.d(TAG, String.format("Accept unsuccessful. %d %s", status.getStatusCode(), status.getStatusMessage())); // revert state connection.setState(ConnectionState.AUTHENTICATING); } } }); }
Example #19
Source File: GeofenceApiHandler.java From PowerSwitch_Android with GNU General Public License v3.0 | 6 votes |
private void addGeofence(GeofencingRequest geofencingRequest, PendingIntent geofencePendingIntent) { if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager .PERMISSION_GRANTED) { return; } LocationServices.GeofencingApi.addGeofences( googleApiClient, geofencingRequest, geofencePendingIntent ).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { switch (status.getStatusCode()) { case CommonStatusCodes.SUCCESS: StatusMessageHandler.showInfoMessage(context, R.string.geofence_enabled, Snackbar.LENGTH_SHORT); } Log.d(GeofenceApiHandler.class, status.toString()); } }); }
Example #20
Source File: NearbyClient.java From 8bitartist with Apache License 2.0 | 6 votes |
/** * Begin advertising for Nearby Connections. */ public void startAdvertising() { long NO_TIMEOUT = 0L; Nearby.Connections.startAdvertising(mGoogleApiClient, null, null, NO_TIMEOUT, myConnectionRequestListener) .setResultCallback(new ResultCallback<Connections.StartAdvertisingResult>() { @Override public void onResult(Connections.StartAdvertisingResult result) { if (result.getStatus().isSuccess()) { Log.d(TAG, "Advertising as " + result.getLocalEndpointName()); mState = STATE_ADVERTISING; } else { Log.w(TAG, "Failed to start advertising: " + result.getStatus()); mState = STATE_IDLE; } } }); }
Example #21
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
@OnClick(R.id.btn_stop_session) public void stopSession() { PendingResult<SessionStopResult> pendingResult = Fitness.SessionsApi.stopSession(mGoogleApiClient, mSession.getIdentifier()); pendingResult.setResultCallback(new ResultCallback<SessionStopResult>() { @Override public void onResult(SessionStopResult sessionStopResult) { if( sessionStopResult.getStatus().isSuccess() ) { Log.i("Tuts+", "Successfully stopped session"); if( sessionStopResult.getSessions() != null && !sessionStopResult.getSessions().isEmpty() ) { Log.i("Tuts+", "Session name: " + sessionStopResult.getSessions().get(0).getName()); Log.i("Tuts+", "Session start: " + sessionStopResult.getSessions().get(0).getStartTime(TimeUnit.MILLISECONDS)); Log.i("Tuts+", "Session end: " + sessionStopResult.getSessions().get(0).getEndTime(TimeUnit.MILLISECONDS)); } } else { Log.i("Tuts+", "Failed to stop session: " + sessionStopResult.getStatus().getStatusMessage()); } } }); }
Example #22
Source File: FileManager.java From amiibo with GNU General Public License v2.0 | 6 votes |
@DebugLog private void createAmiiboFolder() { MetadataChangeSet changeSet = new MetadataChangeSet.Builder() .setTitle(AMIIBO_FOLDER).build(); Drive.DriveApi.getRootFolder(_parent.getClient()) .createFolder(_parent.getClient(), changeSet) .setResultCallback(new ResultCallback<DriveFolder.DriveFolderResult>() { @Override public void onResult(DriveFolder.DriveFolderResult driveFolderResult) { if (driveFolderResult.getStatus().isSuccess()) { app_folder_for_user = driveFolderResult.getDriveFolder(); listFiles(); } else { app_folder_for_user = null; _parent.onPushFinished(); } } }); }
Example #23
Source File: SuggestionsProvider.java From Nibo with MIT License | 6 votes |
public Observable<Place> getPlaceByID(final String placeId) { return new Observable<Place>() { @Override protected void subscribeActual(final Observer<? super Place> observer) { Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId) .setResultCallback(new ResultCallback<PlaceBuffer>() { @Override public void onResult(@NonNull PlaceBuffer places) { if (places.getStatus().isSuccess()) { final Place thatPlace = places.get(0); LatLng queriedLocation = thatPlace.getLatLng(); Log.v("Latitude is", "" + queriedLocation.latitude); Log.v("Longitude is", "" + queriedLocation.longitude); observer.onNext(thatPlace.freeze()); } else { } places.release(); } }); } }.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); }
Example #24
Source File: MainActivity.java From DronesWear with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onConnected(Bundle bundle) { Wearable.DataApi.addListener(mGoogleApiClient, this); if (mDrone != null) { Message.sendActionTypeMessage(mDrone.getCurrentAction(), mGoogleApiClient); } sendInteractionType(); // launch the app on the wear Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).setResultCallback( new ResultCallback<NodeApi.GetConnectedNodesResult>() { @Override public void onResult(@NonNull NodeApi.GetConnectedNodesResult getConnectedNodesResult) { for (Node node : getConnectedNodesResult.getNodes()) { Wearable.MessageApi.sendMessage(mGoogleApiClient, node.getId(), Message.OPEN_ACTIVITY_MESSAGE, new byte[0]); } } }); }
Example #25
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
public void onDeleteEventsClicked(View v) { if (mGoogleApiClient.isConnected()) { Wearable.DataApi.getDataItems(mGoogleApiClient) .setResultCallback(new ResultCallback<DataItemBuffer>() { @Override public void onResult(DataItemBuffer result) { if (result.getStatus().isSuccess()) { deleteDataItems(result); } else { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onDeleteEventsClicked(): failed to get Data Items"); } } result.close(); } }); } else { Log.e(TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services"); } }
Example #26
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
/** * Sends the asset that was created form the photo we took by adding it to the Data Item store. */ private void sendPhoto(Asset asset) { PutDataMapRequest dataMap = PutDataMapRequest.create(IMAGE_PATH); dataMap.getDataMap().putAsset(IMAGE_KEY, asset); dataMap.getDataMap().putLong("time", new Date().getTime()); PutDataRequest request = dataMap.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataItemResult>() { @Override public void onResult(DataItemResult dataItemResult) { LOGD(TAG, "Sending image was successful: " + dataItemResult.getStatus() .isSuccess()); } }); }
Example #27
Source File: WatchMainActivity.java From android-wear-gopro-remote with Apache License 2.0 | 6 votes |
void findPhoneNode() { PendingResult<NodeApi.GetConnectedNodesResult> pending = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient); pending.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() { @Override public void onResult(NodeApi.GetConnectedNodesResult result) { if(result.getNodes().size()>0) { mPhoneNode = result.getNodes().get(0); if(Logger.DEBUG) Logger.debug(TAG, "Found wearable: name=" + mPhoneNode.getDisplayName() + ", id=" + mPhoneNode.getId()); sendConnectMessage(); } else { mPhoneNode = null; updateStatusUi(null); } } }); }
Example #28
Source File: VideoCastManager.java From UTubeTV with The Unlicense | 6 votes |
/** * Loads a media. For this to succeed, you need to have successfully launched the application. * * @param media * @param autoPlay If <code>true</code>, playback starts after load * @param position Where to start the playback (only used if autoPlay is <code>true</code>. * Units is milliseconds. * @param customData Optional JSONObject data to be passed to the cast device * @throws NoConnectionException * @throws TransientNetworkDisconnectionException */ public void loadMedia(MediaInfo media, boolean autoPlay, int position, JSONObject customData) throws TransientNetworkDisconnectionException, NoConnectionException { CastUtils.LOGD(TAG, "loadMedia: " + media); checkConnectivity(); if (media == null) { return; } if (mRemoteMediaPlayer == null) { CastUtils.LOGE(TAG, "Trying to load a video with no active media session"); throw new NoConnectionException(); } mRemoteMediaPlayer.load(mApiClient, media, autoPlay, position, customData) .setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() { @Override public void onResult(MediaChannelResult result) { if (!result.getStatus().isSuccess()) { onFailed(R.string.failed_load, result.getStatus().getStatusCode()); } } }); }
Example #29
Source File: RxSmartLockPasswordsFragment.java From RxSocialAuth with Apache License 2.0 | 5 votes |
private void disableAutoSignIn() { Auth.CredentialsApi.disableAutoSignIn(mCredentialsApiClient).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { mCredentialsApiClient.disconnect(); mStatusSubject.onNext(new RxStatus(status)); mStatusSubject.onCompleted(); } }); }
Example #30
Source File: RxSmartLockPasswordsFragment.java From RxSocialAuth with Apache License 2.0 | 5 votes |
private void requestCredential() { // 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) { mCredentialsApiClient.disconnect(); mRequestSubject.onNext(credentialRequestResult); mRequestSubject.onCompleted(); } }); }