com.google.android.gms.common.api.CommonStatusCodes Java Examples
The following examples show how to use
com.google.android.gms.common.api.CommonStatusCodes.
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: BeaconsFragment.java From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void handleUnsuccessfulNearbyResult(Status status) { Log.v(TAG, "Processing error, status = " + status); if (mResolvingError) { // Already attempting to resolve an error. return; } else if (status.hasResolution()) { try { mResolvingError = true; status.startResolutionForResult(getActivity(), REQUEST_RESOLVE_ERROR); } catch (IntentSender.SendIntentException e) { mResolvingError = false; Log.v(TAG, "Failed to resolve error status.", e); } } else { if (status.getStatusCode() == CommonStatusCodes.NETWORK_ERROR) { Toast.makeText(getActivity(), "No connectivity, cannot proceed. Fix in 'Settings' and try again.", Toast.LENGTH_LONG).show(); } else { // To keep things simple, pop a toast for all other error messages. Toast.makeText(getActivity(), "Unsuccessful: " + status.getStatusMessage(), Toast.LENGTH_LONG).show(); } } }
Example #2
Source File: GeofenceApiHandler.java From PowerSwitch_Android with GNU General Public License v3.0 | 6 votes |
private void removeGeofence(GoogleApiClient googleApiClient, final String geofenceId) { ArrayList<String> geofenceIds = new ArrayList<>(); geofenceIds.add(geofenceId); LocationServices.GeofencingApi.removeGeofences( googleApiClient, geofenceIds ).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { switch (status.getStatusCode()) { case CommonStatusCodes.SUCCESS: StatusMessageHandler.showInfoMessage(context, R.string.geofence_disabled, Snackbar.LENGTH_SHORT); } Log.d(GeofenceApiHandler.class, status.toString()); } }); // Result processed in onResult(). }
Example #3
Source File: SendActivity.java From trust-wallet-android-source with GNU General Public License v3.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == BARCODE_READER_REQUEST_CODE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (data != null) { Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject); QRURLParser parser = QRURLParser.getInstance(); String extracted_address = parser.extractAddressFromQrString(barcode.displayValue); if (extracted_address == null) { Toast.makeText(this, R.string.toast_qr_code_no_address, Toast.LENGTH_SHORT).show(); return; } Point[] p = barcode.cornerPoints; toAddressText.setText(extracted_address); } } else { Log.e("SEND", String.format(getString(R.string.barcode_error_format), CommonStatusCodes.getStatusCodeString(resultCode))); } } else { super.onActivityResult(requestCode, resultCode, data); } }
Example #4
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 #5
Source File: CastDeviceControllerImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 6 votes |
@Override public void spontaneousEventReceived(ChromeCastSpontaneousEvent event) { switch (event.getType()) { case MEDIA_STATUS: break; case STATUS: su.litvak.chromecast.api.v2.Status status = (su.litvak.chromecast.api.v2.Status)event.getData(); Application app = status.getRunningApp(); ApplicationMetadata metadata = this.createMetadataFromApplication(app); if (app != null) { this.onApplicationStatusChanged(new ApplicationStatus(app.statusText)); } int activeInputState = status.activeInput ? 1 : 0; int standbyState = status.standBy ? 1 : 0; this.onDeviceStatusChanged(new CastDeviceStatus(status.volume.level, status.volume.muted, activeInputState, metadata, standbyState)); break; case APPEVENT: break; case CLOSE: this.onApplicationDisconnected(CommonStatusCodes.SUCCESS); break; default: break; } }
Example #6
Source File: HomeFragment.java From mobikul-standalone-pos with MIT License | 6 votes |
public void onActivityResult(final int requestCode, int resultCode, Intent intent) { if (requestCode == BARCODE_READER_REQUEST_CODE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (intent != null) { Barcode barcode = intent.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject); Point[] p = barcode.cornerPoints; DataBaseController.getInstanse().getProductByBarcode(getActivity(), barcode.displayValue, new DataBaseCallBack() { @Override public void onSuccess(Object responseData, String successMsg) { binding.getHandler().onClickProduct((Product) responseData); } @Override public void onFailure(int errorCode, String errorMsg) { } }); } else ToastHelper.showToast(getActivity(), "No code found!!", Toast.LENGTH_SHORT); } else Log.e(TAG, String.format(getString(R.string.barcode_error_format), CommonStatusCodes.getStatusCodeString(resultCode))); } }
Example #7
Source File: FlutterBarcodeScannerPlugin.java From flutter_barcode_scanner with MIT License | 6 votes |
/** * Get the barcode scanning results in onActivityResult * * @param requestCode * @param resultCode * @param data * @return */ @Override public boolean onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_BARCODE_CAPTURE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (data != null) { try { Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject); String barcodeResult = barcode.rawValue; pendingResult.success(barcodeResult); } catch (Exception e) { pendingResult.success("-1"); } } else { pendingResult.success("-1"); } pendingResult = null; arguments = null; return true; } else { pendingResult.success("-1"); } } return false; }
Example #8
Source File: GeofenceApiHandler.java From PowerSwitch_Android with GNU General Public License v3.0 | 6 votes |
/** * Remove all Geofences from Google Location Api */ public void removeAllGeofences() { LocationServices.GeofencingApi.removeGeofences( googleApiClient, // This is the same pending intent that was used in addGeofence(). getGeofencePendingIntent() ).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { switch (status.getStatusCode()) { case CommonStatusCodes.SUCCESS: StatusMessageHandler.showInfoMessage(context, R.string.geofences_disabled, Snackbar .LENGTH_LONG); } Log.d(GeofenceApiHandler.class, status.toString()); } }); // Result processed in onResult(). }
Example #9
Source File: OtpBroadcastReceiver.java From react-native-otp-verify with MIT License | 6 votes |
@Override public void onReceive(Context context, Intent intent) { String o = intent.getAction(); if (SmsRetriever.SMS_RETRIEVED_ACTION.equals(o)) { Bundle extras = intent.getExtras(); Status status = (Status) extras.get(SmsRetriever.EXTRA_STATUS); switch (status.getStatusCode()) { case CommonStatusCodes.SUCCESS: // Get SMS message contents String message = (String) extras.get(SmsRetriever.EXTRA_SMS_MESSAGE); receiveMessage(message); Log.d("SMS", message); break; case CommonStatusCodes.TIMEOUT: Log.d("SMS", "Timeout error"); mContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(EVENT, "Timeout Error."); break; } } }
Example #10
Source File: OcrCaptureActivity.java From android-vision with Apache License 2.0 | 6 votes |
/** * onTap is called to capture the first TextBlock under the tap location and return it to * the Initializing Activity. * * @param rawX - the raw position of the tap * @param rawY - the raw position of the tap. * @return true if the activity is ending. */ private boolean onTap(float rawX, float rawY) { OcrGraphic graphic = mGraphicOverlay.getGraphicAtLocation(rawX, rawY); TextBlock text = null; if (graphic != null) { text = graphic.getTextBlock(); if (text != null && text.getValue() != null) { Intent data = new Intent(); data.putExtra(TextBlockObject, text.getValue()); setResult(CommonStatusCodes.SUCCESS, data); finish(); } else { Log.d(TAG, "text data is null"); } } else { Log.d(TAG,"no text detected"); } return text != null; }
Example #11
Source File: MainActivity.java From android-vision with Apache License 2.0 | 6 votes |
/** * Called when an activity you launched exits, giving you the requestCode * you started it with, the resultCode it returned, and any additional * data from it. The <var>resultCode</var> will be * {@link #RESULT_CANCELED} if the activity explicitly returned that, * didn't return any result, or crashed during its operation. * <p/> * <p>You will receive this call immediately before onResume() when your * activity is re-starting. * <p/> * * @param requestCode The integer request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode The integer result code returned by the child activity * through its setResult(). * @param data An Intent, which can return result data to the caller * (various data can be attached to Intent "extras"). * @see #startActivityForResult * @see #createPendingResult * @see #setResult(int) */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_BARCODE_CAPTURE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (data != null) { Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject); statusMessage.setText(R.string.barcode_success); barcodeValue.setText(barcode.displayValue); Log.d(TAG, "Barcode read: " + barcode.displayValue); } else { statusMessage.setText(R.string.barcode_failure); Log.d(TAG, "No barcode captured, intent data is null"); } } else { statusMessage.setText(String.format(getString(R.string.barcode_error), CommonStatusCodes.getStatusCodeString(resultCode))); } } else { super.onActivityResult(requestCode, resultCode, data); } }
Example #12
Source File: MainActivity.java From journaldev with MIT License | 6 votes |
@Override public void onResult(@NonNull CredentialRequestResult credentialRequestResult) { Status status = credentialRequestResult.getStatus(); if (status.isSuccess()) { onCredentialRetrieved(credentialRequestResult.getCredential()); } else { if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) { try { isResolving = true; status.startResolutionForResult(this, RC_READ); } catch (IntentSender.SendIntentException e) { Log.d(TAG, e.toString()); } } else { showHintDialog(); } } }
Example #13
Source File: MainActivity.java From android-vision with Apache License 2.0 | 6 votes |
/** * Called when an activity you launched exits, giving you the requestCode * you started it with, the resultCode it returned, and any additional * data from it. The <var>resultCode</var> will be * {@link #RESULT_CANCELED} if the activity explicitly returned that, * didn't return any result, or crashed during its operation. * <p/> * <p>You will receive this call immediately before onResume() when your * activity is re-starting. * <p/> * * @param requestCode The integer request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode The integer result code returned by the child activity * through its setResult(). * @param data An Intent, which can return result data to the caller * (various data can be attached to Intent "extras"). * @see #startActivityForResult * @see #createPendingResult * @see #setResult(int) */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == RC_OCR_CAPTURE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (data != null) { String text = data.getStringExtra(OcrCaptureActivity.TextBlockObject); statusMessage.setText(R.string.ocr_success); textValue.setText(text); Log.d(TAG, "Text read: " + text); } else { statusMessage.setText(R.string.ocr_failure); Log.d(TAG, "No Text captured, intent data is null"); } } else { statusMessage.setText(String.format(getString(R.string.ocr_error), CommonStatusCodes.getStatusCodeString(resultCode))); } } else { super.onActivityResult(requestCode, resultCode, data); } }
Example #14
Source File: OcrCaptureActivity.java From Questor with MIT License | 6 votes |
/** * onTap is called to capture the first TextBlock under the tap location and return it to * the Initializing Activity. * * @param rawX - the raw position of the tap * @param rawY - the raw position of the tap. * @return true if the activity is ending. */ private boolean onTap(float rawX, float rawY) { OcrGraphic graphic = mGraphicOverlay.getGraphicAtLocation(rawX, rawY); TextBlock text = null; if (graphic != null) { text = graphic.getTextBlock(); if (text != null && text.getValue() != null) { Intent data = new Intent(); data.putExtra(TextBlockObject, text.getValue()); setResult(CommonStatusCodes.SUCCESS, data); finish(); } else { Log.d(TAG, "text data is null"); } } else { Log.d(TAG,"no text detected"); } return text != null; }
Example #15
Source File: MainActivity.java From Questor with MIT License | 6 votes |
/** * Called when an activity you launched exits, giving you the requestCode * you started it with, the resultCode it returned, and any additional * data from it. The <var>resultCode</var> will be * {@link #RESULT_CANCELED} if the activity explicitly returned that, * didn't return any result, or crashed during its operation. * <p/> * <p>You will receive this call immediately before onResume() when your * activity is re-starting. * <p/> * * @param requestCode The integer request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode The integer result code returned by the child activity * through its setResult(). * @param data An Intent, which can return result data to the caller * (various data can be attached to Intent "extras"). * @see #startActivityForResult * @see #createPendingResult * @see #setResult(int) */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == RC_OCR_CAPTURE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (data != null) { String text = data.getStringExtra(OcrCaptureActivity.TextBlockObject); statusMessage.setText(R.string.ocr_success); textValue.setText(text); Log.d(TAG, "Text read: " + text); } else { statusMessage.setText(R.string.ocr_failure); Log.d(TAG, "No Text captured, intent data is null"); } } else { statusMessage.setText(String.format(getString(R.string.ocr_error), CommonStatusCodes.getStatusCodeString(resultCode))); } displayStatus(); } else { super.onActivityResult(requestCode, resultCode, data); } }
Example #16
Source File: IndexService.java From android_packages_apps_GmsCore with Apache License 2.0 | 6 votes |
@Override public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { switch (service) { case INDEX: callback.onPostInitComplete(0, appDataSearch.asBinder(), null); break; case SEARCH_ADMINISTRATION: Log.w(TAG, "Service not yet implemented: " + service); callback.onPostInitComplete(CommonStatusCodes.ERROR, null, null); break; case SEARCH_QUERIES: callback.onPostInitComplete(0, searchQueries.asBinder(), null); break; case SEARCH_GLOBAL: callback.onPostInitComplete(0, globalSearchAdmin.asBinder(), null); break; case SEARCH_CORPORA: callback.onPostInitComplete(0, searchCorpora.asBinder(), null); break; case SEARCH_IME: Log.w(TAG, "Service not yet implemented: " + service); callback.onPostInitComplete(CommonStatusCodes.ERROR, null, null); break; } }
Example #17
Source File: SafetyNetSampleFragment.java From android-play-safetynet with Apache License 2.0 | 6 votes |
@Override public void onFailure(@NonNull Exception e) { // An error occurred while communicating with the service. mResult = null; if (e instanceof ApiException) { // An error with the Google Play Services API contains some additional details. ApiException apiException = (ApiException) e; Log.d(TAG, "Error: " + CommonStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " + apiException.getStatusMessage()); } else { // A different, unknown type of error occurred. Log.d(TAG, "ERROR! " + e.getMessage()); } }
Example #18
Source File: RxSmartLockPasswordsFragment.java From RxSocialAuth with Apache License 2.0 | 6 votes |
private void resolveResult(Status status) { if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) { try { //status.startResolutionForResult(mActivity, RC_READ); startIntentSenderForResult(status.getResolution().getIntentSender(), RC_READ, null, 0, 0, 0, null); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); mCredentialsApiClient.disconnect(); mAccountSubject.onError(new Throwable(e.toString())); } } else { // The user must create an account or sign in manually. mCredentialsApiClient.disconnect(); mAccountSubject.onError(new Throwable(getString(R.string.status_canceled_request_credential))); } }
Example #19
Source File: OcrCaptureActivity.java From Moneycim with MIT License | 6 votes |
/** * onTap is called to capture the first TextBlock under the tap location and return it to * the Initializing Activity. * * @param rawX - the raw position of the tap * @param rawY - the raw position of the tap. * @return true if the activity is ending. */ private boolean onTap(float rawX, float rawY) { OcrGraphic graphic = mGraphicOverlay.getGraphicAtLocation(rawX, rawY); TextBlock text = null; if (graphic != null) { text = graphic.getTextBlock(); if (text != null && text.getValue() != null) { Intent data = new Intent(); data.putExtra(TextBlockObject, text.getValue()); setResult(CommonStatusCodes.SUCCESS, data); finish(); } else { Log.d(TAG, "text data is null"); } } else { Log.d(TAG,"no text detected"); } return text != null; }
Example #20
Source File: MainActivity.java From OCR-Reader with MIT License | 6 votes |
/** * Called when an activity you launched exits, giving you the requestCode * you started it with, the resultCode it returned, and any additional * data from it. The <var>resultCode</var> will be * {@link #RESULT_CANCELED} if the activity explicitly returned that, * didn't return any result, or crashed during its operation. * <p/> * <p>You will receive this call immediately before onResume() when your * activity is re-starting. * <p/> * * @param requestCode The integer request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode The integer result code returned by the child activity * through its setResult(). * @param data An Intent, which can return result data to the caller * (various data can be attached to Intent "extras"). * @see #startActivityForResult * @see #createPendingResult * @see #setResult(int) */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == RC_OCR_CAPTURE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (data != null) { String text = data.getStringExtra(OcrCaptureActivity.TextBlockObject); statusMessage.setText(R.string.ocr_success); textValue.setText(text); Log.d(TAG, "Text read: " + text); } else { statusMessage.setText(R.string.ocr_failure); Log.d(TAG, "No Text captured, intent data is null"); } } else { statusMessage.setText(String.format(getString(R.string.ocr_error), CommonStatusCodes.getStatusCodeString(resultCode))); } } else { super.onActivityResult(requestCode, resultCode, data); } }
Example #21
Source File: OcrCaptureActivity.java From OCR-Reader with MIT License | 6 votes |
/** * onTap is called to capture the first TextBlock under the tap location and return it to * the Initializing Activity. * * @param rawX - the raw position of the tap * @param rawY - the raw position of the tap. * @return true if the activity is ending. */ private boolean onTap(float rawX, float rawY) { OcrGraphic graphic = mGraphicOverlay.getGraphicAtLocation(rawX, rawY); TextBlock text = null; if (graphic != null) { text = graphic.getTextBlock(); if (text != null && text.getValue() != null) { Intent data = new Intent(); data.putExtra(TextBlockObject, text.getValue()); setResult(CommonStatusCodes.SUCCESS, data); finish(); } else { Log.d(TAG, "text data is null"); } } else { Log.d(TAG,"no text detected"); } return text != null; }
Example #22
Source File: GooglePlusNetwork.java From EasyLogin with MIT License | 6 votes |
private void parseGoogleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { sharedPrefs.edit().putBoolean(GPLUS_CONNECTED, true).apply(); setSignInButtonEnabled(false); GoogleSignInAccount acct = result.getSignInAccount(); if (acct != null) { accessToken = new AccessToken.Builder(acct.getId()) .email(acct.getEmail()) .userName(acct.getDisplayName()) .userId(acct.getId()) .build(); listener.onLoginSuccess(getNetwork()); } } else { if (result.getStatus().getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) { if (listener != null) { requestLogin(listener); } return; } sharedPrefs.edit().putBoolean(GPLUS_CONNECTED, false).apply(); setSignInButtonEnabled(true); listener.onError(getNetwork(), getStatusCodeString(result.getStatus().getStatusCode())); } }
Example #23
Source File: CastDeviceControllerImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
@Override public void launchApplication(String applicationId, LaunchOptions launchOptions) { Application app = null; try { app = this.chromecast.launchApp(applicationId); } catch (IOException e) { Log.w(TAG, "Error launching cast application: " + e.getMessage()); this.onApplicationConnectionFailure(CommonStatusCodes.NETWORK_ERROR); return; } this.sessionId = app.sessionId; ApplicationMetadata metadata = this.createMetadataFromApplication(app); this.onApplicationConnectionSuccess(metadata, app.statusText, app.sessionId, true); }
Example #24
Source File: BarcodeCaptureActivity.java From fuse-qreader with MIT License | 5 votes |
public void updateResult(Barcode barcode){ if(barcode != null){ Intent data = new Intent(); data.putExtra(BarcodeObject, barcode); setResult(CommonStatusCodes.SUCCESS, data); finish(); } }
Example #25
Source File: GoogleApiClientBridge.java From friendspell with Apache License 2.0 | 5 votes |
public void getProfileImages( String token, final List<String> userIds, final GetProfileImagesCallback callback) { ArrayList<String> toFetch = new ArrayList<>(); for (int i = 0; i < userIds.size(); ++i) { String userId = userIds.get(i); if (!profileImages.containsKey(userId)) { toFetch.add(userId); } } GoogleApiClient googleApiClient = clients.get(token); if (googleApiClient == null) { return; } Plus.PeopleApi.load(googleApiClient, userIds).setResultCallback( new ResultCallback<People.LoadPeopleResult>() { @Override public void onResult(People.LoadPeopleResult peopleData) { if (peopleData.getStatus().getStatusCode() == CommonStatusCodes.SUCCESS) { PersonBuffer personBuffer = peopleData.getPersonBuffer(); try { int count = personBuffer.getCount(); for (int i = 0; i < count; ++i) { Person person = personBuffer.get(i); profileImages.put(person.getId(), getProfileImageUrl(person)); } callback.onSuccess(); } finally { personBuffer.close(); } } else { Timber.e("Error requesting people data: %s", peopleData.getStatus()); } } }); }
Example #26
Source File: BarcodeCaptureActivity.java From BarcodeReaderSample with MIT License | 5 votes |
@Override public void onDetectedQrCode(Barcode barcode) { if (barcode != null) { Intent intent = new Intent(); intent.putExtra(BarcodeObject, barcode); setResult(CommonStatusCodes.SUCCESS, intent); finish(); } }
Example #27
Source File: CastDeviceControllerImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
@Override public void sendMessage(String namespace, String message, long requestId) { try { this.chromecast.sendRawRequest(namespace, message, requestId); } catch (IOException e) { Log.w(TAG, "Error sending cast message: " + e.getMessage()); this.onSendMessageFailure("", requestId, CommonStatusCodes.NETWORK_ERROR); return; } }
Example #28
Source File: CapabilityManager.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
public int remove(String capability) { if (!this.capabilities.contains(capability)) { return WearableStatusCodes.UNKNOWN_CAPABILITY; } wearable.deleteDataItems(buildCapabilityUri(capability, true), packageName); capabilities.remove(capability); return CommonStatusCodes.SUCCESS; }
Example #29
Source File: GamesStubService.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
@Override public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { String packageName = null; if (request.extras != null) { packageName = request.extras.getString(PARAM_GAME_PACKAGE_NAME); } if (packageName == null) packageName = GMS_PACKAGE_NAME; Intent intent = new Intent(ACTION_PLAY_GAMES_UPGRADE); intent.setPackage(GMS_PACKAGE_NAME); intent.putExtra(EXTRA_GAME_PACACKE_NAME, packageName); Bundle bundle = new Bundle(); bundle.putParcelable("pendingIntent", PendingIntent.getActivity(this, packageName.hashCode(), intent, FLAG_UPDATE_CURRENT)); callback.onPostInitComplete(CommonStatusCodes.RESOLUTION_REQUIRED, null, bundle); }
Example #30
Source File: StorableFenceManagerTest.java From JCVD with MIT License | 5 votes |
@Test public void testAddSucceed() { StorableFence fence = StorableHeadphoneFence.during(HeadphoneState.PLUGGED_IN); mManager.addFence("fenceId", fence, ""); // when the gapi is connected, the fence should be added to the gapi // nothing in the stores should change assertThat(mAddedCalls, is(0)); assertThat(mRemovedCalls, is(0)); assertThat(mMockGapiFenceManager.addResultDict.containsKey("fenceId"), is(true)); assertThat(mManager.mToAddStore.getAllFences().size(), is(1)); assertThat(mManager.mToAddStore.getAllFences().get(0), is(fence)); assertThat(mManager.mSyncedStore.getAllFences(), empty()); assertThat(mManager.mToRemoveStore.getAllFences(), empty()); assertThat(mManager.getFence("fenceId"), is(nullValue())); // when the fence is really added to the gapi, the fence should be placed in the syncedStore // and removed from the toAddStore // and the listener should also be called ResultCallback<Status> result = mMockGapiFenceManager.addResultDict.get("fenceId"); result.onResult(new Status(CommonStatusCodes.SUCCESS)); assertThat(mAddedCalls, is(1)); assertThat(mRemovedCalls, is(0)); assertThat(mManager.mToAddStore.getAllFences(), empty()); assertThat(mManager.mSyncedStore.getAllFences().size(), is(1)); assertThat(mManager.mSyncedStore.getAllFences().get(0).equals(fence), is(true)); assertThat(mManager.mToRemoveStore.getAllFences(), empty()); assertThat(mManager.getFence("fenceId"), is(fence)); }