Example usage for com.google.api.client.googleapis.extensions.android.gms.auth GoogleAccountCredential newChooseAccountIntent

List of usage examples for com.google.api.client.googleapis.extensions.android.gms.auth GoogleAccountCredential newChooseAccountIntent

Introduction

In this page you can find the example usage for com.google.api.client.googleapis.extensions.android.gms.auth GoogleAccountCredential newChooseAccountIntent.

Prototype

public final Intent newChooseAccountIntent() 

Source Link

Document

Returns an intent to show the user to select a Google account, or create a new one if there are none on the device yet.

Usage

From source file:com.google.cloud.genomics.android.CredentialActivity.java

License:Apache License

protected void checkCredential() {
    GoogleAccountCredential credential = getCredential(this);

    if (credential.getSelectedAccountName() == null) {
        startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
    } else if (!isDeviceOnline(this)) {
        Toast.makeText(this, "No network connection available, this app won't show any data.",
                Toast.LENGTH_SHORT).show();
    } else {//from  w  w w  .j a  va  2s.com
        credentialAvailable = true;
        handleCredential();
    }
}

From source file:com.meiste.tempalarm.ui.CurrentTemp.java

License:Apache License

@Override
protected void onResume() {
    super.onResume();
    mSyncStatusObserver.onStatusChanged(0);

    if (checkPlayServices()) {
        final GoogleAccountCredential credential = AccountUtils.getCredential(this);
        if (credential.getSelectedAccountName() != null) {
            GCMHelper.registerIfNeeded(getApplicationContext(), AppConstants.GCM_SENDER_ID, this);
        } else {//from w  w w .ja  v  a2  s  .  co m
            startActivityForResult(credential.newChooseAccountIntent(), ACCOUNT_PICKER_REQUEST);
        }

        // Watch for sync state changes
        final int mask = ContentResolver.SYNC_OBSERVER_TYPE_PENDING | ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE;
        mSyncObserverHandle = ContentResolver.addStatusChangeListener(mask, mSyncStatusObserver);
    }
}