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


Java CommonStatusCodes類代碼示例

本文整理匯總了Java中com.google.android.gms.common.api.CommonStatusCodes的典型用法代碼示例。如果您正苦於以下問題:Java CommonStatusCodes類的具體用法?Java CommonStatusCodes怎麽用?Java CommonStatusCodes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CommonStatusCodes類屬於com.google.android.gms.common.api包,在下文中一共展示了CommonStatusCodes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onActivityResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == PROFILE_REQUEST && resultCode == CommonStatusCodes.SUCCESS) {
        preferences.setIdAuth("");
        preferences.setUserData("");
        preferences.setUserDni("");
        preferences.setEmail("");
        preferences.setIsLogged(false);
        setDataToHeader(preferences);
        if (!(getSupportFragmentManager().findFragmentById(R.id.containerHome) instanceof MapFragment)) {
            navigationView.getMenu().getItem(0).setChecked(true);
            setTitleToolbar(getString(R.string.map_stations));
            getSupportFragmentManager().popBackStack("", FragmentManager.POP_BACK_STACK_INCLUSIVE);
        }
    } else if (requestCode == 140) {
        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.containerHome);
        if (fragment != null && fragment instanceof MapFragment) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    } else if (resultCode == Activity.RESULT_OK && requestCode == LoginActivity.LOGIN_RESULT) {
        navigationView.getMenu().getItem(itemSelected).setChecked(true);
        preferences.setIsLogged(true);
        setDataToHeader(preferences);
    }
}
 
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:27,代碼來源:HomeActivity.java

示例2: handleSignInResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
protected void handleSignInResult(GoogleSignInResult result) {
    Schedulers.newThread()
            .scheduleDirect(() -> {
                if (result.isSuccess()) {
                    if (result.getSignInAccount() != null && result.getSignInAccount().getAccount() != null) {
                        Account account = result.getSignInAccount().getAccount();
                        try {
                            String token = GoogleAuthUtil.getToken(activity, account, "oauth2:" + SCOPE_PICASA);
                            emitter.onSuccess(new GoogleSignIn.SignInAccount(token, result.getSignInAccount()));
                        } catch (IOException | GoogleAuthException e) {
                            emitter.onError(new SignInException("SignIn", e));
                        }
                    } else {
                        emitter.onError(new SignInException("SignIn", "getSignInAccount is null!", 0));
                    }

                } else {
                    if (result.getStatus().getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) {
                        emitter.onError(new SignInRequiredException());
                    } else {
                        emitter.onError(new SignInException("SignIn", result.getStatus().getStatusMessage(), result.getStatus().getStatusCode()));
                    }
                }
            });
}
 
開發者ID:yosriz,項目名稱:RxGooglePhotos,代碼行數:26,代碼來源:GoogleSignInOnSubscribeBase.java

示例3: onTap

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:DevipriyaSarkar,項目名稱:OCR-Reader,代碼行數:29,代碼來源:OcrCaptureActivity.java

示例4: onActivityResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:DevipriyaSarkar,項目名稱:OCR-Reader,代碼行數:45,代碼來源:MainActivity.java

示例5: onActivityResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:TrustWallet,項目名稱:trust-wallet-android,代碼行數:25,代碼來源:SendActivity.java

示例6: resolveResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
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)));
    }
}
 
開發者ID:pchmn,項目名稱:RxSocialAuth,代碼行數:18,代碼來源:RxSmartLockPasswordsFragment.java

示例7: signOut

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
/**
 * Facebook sign out
 */
public void signOut(PublishSubject<RxStatus> statusSubject) {
    LoginManager.getInstance().logOut();
    // delete current user
    deleteCurrentUser();
    statusSubject.onNext(new RxStatus(
            CommonStatusCodes.SUCCESS,
            getString(R.string.status_success_log_out_message)
    ));
    statusSubject.onCompleted();
}
 
開發者ID:pchmn,項目名稱:RxSocialAuth,代碼行數:14,代碼來源:RxFacebookAuthFragment.java

示例8: handleUnsuccessfulNearbyResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
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();
        }
    }
}
 
開發者ID:NordicSemiconductor,項目名稱:Android-nRF-Beacon-for-Eddystone,代碼行數:27,代碼來源:BeaconsFragment.java

示例9: onActivityResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
/**
 * 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);


 }
}
 
開發者ID:thegenuinegourav,項目名稱:Questor,代碼行數:48,代碼來源:MainActivity.java

示例10: onFailure

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
@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());
    }

}
 
開發者ID:googlesamples,項目名稱:android-play-safetynet,代碼行數:18,代碼來源:SafetyNetSampleFragment.java

示例11: handleUnsuccessfulNearbyResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
@VisibleForTesting
protected void handleUnsuccessfulNearbyResult(Status status) {
    Log.v(TAG, "Processing error, status = " + status);

    if (resolvingError) {
        // Already attempting to resolve an error.
        return;
    } else if (status.hasResolution()) {
        try {
            resolvingError = true;
            status.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
        } catch (Exception e) {
            resolvingError = false;
            Log.v(TAG, "Failed to resolve error status.", e);
        }
    } else {
        if (status.getStatusCode() == CommonStatusCodes.NETWORK_ERROR) {
            Toast.makeText(this,
                    "No connectivity, cannot proceed. Fix in 'Settings' and try again.",
                    Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "Unsuccessful: " + status.getStatusMessage(),
                    Toast.LENGTH_LONG).show();
        }
    }
}
 
開發者ID:sourceallies,項目名稱:zonebeacon,代碼行數:27,代碼來源:TransferActivity.java

示例12: onTap

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
/**
 * onTap is called to capture the oldest barcode currently detected and
 * return it to the caller.
 *
 * @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) {

    //TODO: use the tap position to select the barcode.
    BarcodeGraphic graphic = mGraphicOverlay.getFirstGraphic();
    Barcode barcode = null;
    if (graphic != null) {
        barcode = graphic.getBarcode();
        if (barcode != null) {
            Intent data = new Intent();
            data.putExtra(BarcodeObject, barcode);
            setResult(CommonStatusCodes.SUCCESS, data);
            finish();
        }
        else {
            Log.d(TAG, "barcode data is null");
        }
    }
    else {
        Log.d(TAG,"no barcode detected");
    }
    return barcode != null;
}
 
開發者ID:ashishsurana,項目名稱:qrcode-reader,代碼行數:31,代碼來源:BarcodeCaptureActivity.java

示例13: onActivityResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:ashishsurana,項目名稱:qrcode-reader,代碼行數:45,代碼來源:MainActivity.java

示例14: onActivityResult

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "onActivityResult");
    if (requestCode == RC_BARCODE_CAPTURE) {
        if (resultCode == CommonStatusCodes.SUCCESS) {
            if (data != null) {
                Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
                Log.d(TAG, "Barcode read: " + barcode.displayValue);
                mPresenter.newEvent(barcode);
            } else {
                Log.d(TAG, "No barcode captured, intent data is null");
            }
        } else {
            Log.d(TAG, "onActivityResult is not a success");
        }
    }
    else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
開發者ID:compte14031879,項目名稱:udacity-capstone,代碼行數:21,代碼來源:EventsFragment.java

示例15: onConnected

import com.google.android.gms.common.api.CommonStatusCodes; //導入依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
    googleApi.requestCredentials(new ResultCallback<CredentialRequestResult>() {
        @Override
        public void onResult(@NonNull CredentialRequestResult result) {
            if (result.getStatus().isSuccess()) {
                onCredentialRetrieved(result.getCredential());
            } else if (result.getStatus().getStatusCode() != CommonStatusCodes.SIGN_IN_REQUIRED && result.getStatus().hasResolution()) {
                try {
                    result.getStatus().startResolutionForResult(LoginActivity.this, GoogleApiAdapter.RETRIEVE_CREDENTIALS);
                } catch (IntentSender.SendIntentException e) {
                    Snackbar.make(vLoginForm, R.string.error_smartlock_failed, Snackbar.LENGTH_LONG);
                }
            }
        }
    });
}
 
開發者ID:Sefford,項目名稱:BeAuthentic,代碼行數:18,代碼來源:LoginActivity.java


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