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


Java Scope類代碼示例

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


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

示例1: LoginGoogle

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
public LoginGoogle(final Context context, SignInButton button, final Activity act, PreferencesShared pref) {
    this.context = context;
    preferencesShared = pref;
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
    gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN)).requestScopes(new Scope(Scopes.PLUS_ME)).requestEmail().requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
    mGoogleApiClient = new GoogleApiClient.Builder(context.getApplicationContext())
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    button.setSize(SignInButton.SIZE_STANDARD);
    button.setScopes(gso.getScopeArray());

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            act.startActivityForResult(signInIntent, 101);

        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:24,代碼來源:LoginGoogle.java

示例2: initGoogleApiClient

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
private void initGoogleApiClient() {
    final GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestProfile()
            .requestScopes(new Scope(SCOPE_PICASA))
            .build();
    googleApiClient = new GoogleApiClient.Builder(activity)
            .enableAutoManage(activity,
                    connectionResult -> emitter.onError(new SignInException("Connecting", connectionResult.getErrorMessage(), connectionResult.getErrorCode())))
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(@Nullable Bundle bundle) {
                    actWhenConnected();
                }

                @Override
                public void onConnectionSuspended(int i) {

                }
            })
            .build();
}
 
開發者ID:yosriz,項目名稱:RxGooglePhotos,代碼行數:24,代碼來源:GoogleSignOutOnSubscribe.java

示例3: init

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
public void init (final int instanceID) {
	script_id = instanceID;
	GUtils.setScriptInstance(script_id);

	if (GUtils.checkGooglePlayService(activity)) {
		Log.d(TAG, "Play Service Available.");
	}

	GoogleSignInOptions gso =
	new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
	.requestScopes(new Scope(Scopes.GAMES))
	.requestEmail()
	.build();

	mGoogleSignInClient = GoogleSignIn.getClient(activity, gso);

	Log.d(TAG, "Google::Initialized");
	onStart();
}
 
開發者ID:FrogSquare,項目名稱:GodotGoogleService,代碼行數:20,代碼來源:PlayService.java

示例4: loginGoogleAPI

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
private void loginGoogleAPI() {
    if (!(context instanceof FragmentActivity)) {
        return;
    }
    gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestProfile()
            .requestId()
            .requestScopes(new Scope(Scopes.PLUS_LOGIN), new Scope(Scopes.DRIVE_FILE))
            .requestServerAuthCode(CLIENT_ID)
            .build();
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(context)
            .addApi(com.google.android.gms.auth.api.Auth.GOOGLE_SIGN_IN_API, gso)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    }
    if (!mGoogleApiClient.isConnected()) {
        mGoogleApiClient.connect();
    } else {
        sendAuthRequest();
    }
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:25,代碼來源:GoogleAPIHelper.java

示例5: exchangeServerAuthCodeForJWT

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
private void exchangeServerAuthCodeForJWT(String firebaseUserId, String authCode, Set<Scope> grantedScopes, final SimpleCallback<String> jwtCallback) {
    Ion.with(context)
            .load(context.getString(R.string.APP_URL) + "/exchangeServerAuthCodeForJWT")
            .setBodyParameter("serverCode", authCode)
            .setBodyParameter("firebaseUserId", firebaseUserId)
            .setBodyParameter("grantedScopes", android.text.TextUtils.join(",", grantedScopes))
            .asJsonObject()
            .setCallback(new com.koushikdutta.async.future.FutureCallback<JsonObject>() {
                @Override
                public void onCompleted(Exception e, JsonObject result) {
                    if (e != null) {
                        jwtCallback.onError(e);
                        return;
                    }
                    String jwt = result.get("serviceAccessToken").getAsString();
                    AuthHelper.userJwt = jwt;
                    jwtCallback.onComplete(jwt);
                }
            });
}
 
開發者ID:dan-silver,項目名稱:cast-dashboard-android-app,代碼行數:21,代碼來源:AuthHelper.java

示例6: requestPermissions

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Override
public int requestPermissions(Activity activity) {
    AuthHelper authHelper = new AuthHelper(context);

    Set<Scope> scopes = new HashSet<>();
    scopes.addAll(AuthHelper.grantedScopes);
    scopes.add(new Scope(RequiredScope));

    GoogleApiClient mGoogleApiClient = new GoogleApiClient
        .Builder(context)
        .addApi(Auth.GOOGLE_SIGN_IN_API, authHelper.getGoogleGSO(scopes))
        .build();

    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    activity.startActivityForResult(signInIntent, GoogleCalendarSettings.PERMISSIONS_REQUEST_READ_GOOGLE_CALENDAR);

    return GoogleCalendarSettings.PERMISSIONS_REQUEST_READ_GOOGLE_CALENDAR;
}
 
開發者ID:dan-silver,項目名稱:cast-dashboard-android-app,代碼行數:19,代碼來源:GoogleCalendarWidget.java

示例7: createConnection

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
public void createConnection(AppCompatActivity mActivity)
{

	this.activity = mActivity;
	userData = new UserLoginDetails();

	if (Utility.checkPlayServices(mActivity)) {

		GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
				.requestScopes(new Scope(Scopes.PROFILE))
				.requestScopes(new Scope(Scopes.PLUS_LOGIN))
				.requestProfile()
				.requestEmail()
				.build();

		if (mGoogleApiClient == null) {
			// [START create_google_api_client]
			// Build GoogleApiClient with access to basic profile
			mGoogleApiClient = new GoogleApiClient.Builder(mActivity)
					.enableAutoManage(mActivity,this)
					.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
					//.addApi(Plus.API)
					.build();
		}
	}
}
 
開發者ID:WasimMemon,項目名稱:SocialSignIn_Demo,代碼行數:27,代碼來源:GooglePlusLoginHelper.java

示例8: testLoginGoogleSuccess

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Test public void testLoginGoogleSuccess() throws Exception {
    InOrder inOrder = inOrder(mMockGoogleApiClient);
    mRxLogin.mGoogleApiClient = mMockGoogleApiClient;
    mRxLogin.loginGoogle(mActivity, new Scope(Scopes.PLUS_LOGIN))
        .subscribe(mGoogleSubscriber);
    // wait for connection
    Thread.sleep(20);
    mRxLogin.mGoogleCallback.onSuccess(mGoogleSignInResult);
    mGoogleSubscriber.awaitTerminalEvent();
    verify(mActivity).startActivityForResult(eq(mTestIntent), eq(5712));
    inOrder.verify(mMockGoogleApiClient).blockingConnect(eq(10L), eq(TimeUnit.SECONDS));
    inOrder.verify(mMockGoogleApiClient).disconnect();
    mGoogleSubscriber.assertNoErrors();
    mGoogleSubscriber.assertValueCount(1);
    mGoogleSubscriber.assertTerminated();
    assertThat(mRxLogin.mGoogleApiClient).isNull();
    assertThat(mRxLogin.mGoogleCallback).isNull();
}
 
開發者ID:hijamoya,項目名稱:RxLogin,代碼行數:19,代碼來源:RxLoginTest.java

示例9: testLoginGoogleCancel

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Test public void testLoginGoogleCancel() throws Exception {
    InOrder inOrder = inOrder(mMockGoogleApiClient);
    mRxLogin.mGoogleApiClient = mMockGoogleApiClient;
    mRxLogin.loginGoogle(mActivity, new Scope(Scopes.PLUS_LOGIN))
        .subscribe(mGoogleSubscriber);
    // wait for connection
    Thread.sleep(20);
    mRxLogin.mGoogleCallback.onCancel();
    mGoogleSubscriber.awaitTerminalEvent();
    verify(mActivity).startActivityForResult(eq(mTestIntent), eq(5712));
    inOrder.verify(mMockGoogleApiClient).blockingConnect(eq(10L), eq(TimeUnit.SECONDS));
    inOrder.verify(mMockGoogleApiClient).disconnect();
    mGoogleSubscriber.assertError(LoginException.class);
    mGoogleSubscriber.assertTerminated();
    assertThat(mRxLogin.mGoogleApiClient).isNull();
    assertThat(mRxLogin.mGoogleCallback).isNull();
}
 
開發者ID:hijamoya,項目名稱:RxLogin,代碼行數:18,代碼來源:RxLoginTest.java

示例10: testLoginGoogleError

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Test public void testLoginGoogleError() throws Exception {
    InOrder inOrder = inOrder(mMockGoogleApiClient);
    mRxLogin.mGoogleApiClient = mMockGoogleApiClient;
    mRxLogin.loginGoogle(mActivity, new Scope(Scopes.PLUS_LOGIN))
        .subscribe(mGoogleSubscriber);
    // wait for connection
    Thread.sleep(20);
    mRxLogin.mGoogleCallback.onError(mGoogleSignInResult);
    mGoogleSubscriber.awaitTerminalEvent();
    verify(mActivity).startActivityForResult(eq(mTestIntent), eq(5712));
    inOrder.verify(mMockGoogleApiClient).blockingConnect(eq(10L), eq(TimeUnit.SECONDS));
    inOrder.verify(mMockGoogleApiClient).disconnect();
    mGoogleSubscriber.assertError(LoginException.class);
    mGoogleSubscriber.assertTerminated();
    assertThat(mRxLogin.mGoogleApiClient).isNull();
    assertThat(mRxLogin.mGoogleCallback).isNull();
}
 
開發者ID:hijamoya,項目名稱:RxLogin,代碼行數:18,代碼來源:RxLoginTest.java

示例11: testLoginGoogleConnectionError

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Test public void testLoginGoogleConnectionError() throws Exception {
    when(mMockGoogleApiClient.blockingConnect(eq(10L), eq(TimeUnit.SECONDS)))
        .thenReturn(new ConnectionResult(ConnectionResult.API_UNAVAILABLE));
    InOrder inOrder = inOrder(mMockGoogleApiClient);
    mRxLogin.mGoogleApiClient = mMockGoogleApiClient;
    mRxLogin.loginGoogle(mActivity, new Scope(Scopes.PLUS_LOGIN))
        .subscribe(mGoogleSubscriber);
    mGoogleSubscriber.awaitTerminalEvent();
    verify(mActivity).startActivityForResult(eq(mTestIntent), eq(5712));
    inOrder.verify(mMockGoogleApiClient).blockingConnect(eq(10L), eq(TimeUnit.SECONDS));
    inOrder.verify(mMockGoogleApiClient).disconnect();
    mGoogleSubscriber.assertError(LoginException.class);
    mGoogleSubscriber.assertTerminated();
    assertThat(mRxLogin.mGoogleApiClient).isNull();
    assertThat(mRxLogin.mGoogleCallback).isNull();
}
 
開發者ID:hijamoya,項目名稱:RxLogin,代碼行數:17,代碼來源:RxLoginTest.java

示例12: loadDriveApiClients

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
private void loadDriveApiClients() {
    Set<Scope> requiredScopes = new HashSet<>(2);
    requiredScopes.add(Drive.SCOPE_FILE);
    requiredScopes.add(Drive.SCOPE_APPFOLDER);

    GoogleSignInAccount signInAccount = GoogleSignIn.getLastSignedInAccount(getContext());
    if (signInAccount != null && signInAccount.getGrantedScopes().containsAll(requiredScopes)) {
        initializeDriveClient(signInAccount);
    } else {
        GoogleSignInOptions signInOptions =
                new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                        .requestScopes(Drive.SCOPE_FILE)
                        .requestScopes(Drive.SCOPE_APPFOLDER)
                        .build();
        GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(getActivity(), signInOptions);
        startActivityForResult(googleSignInClient.getSignInIntent(), REQUEST_RESOLVE_ERROR);
    }
}
 
開發者ID:canyapan,項目名稱:DietDiaryApp,代碼行數:19,代碼來源:SettingsSupportFragment.java

示例13: onCreate

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.historydata_layout);

    mClient = new GoogleApiClient.Builder(this)
            .addApi(Fitness.HISTORY_API)
            .addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ))
            .addScope(new Scope(Scopes.FITNESS_BODY_READ))
            .addScope(new Scope(Scopes.FITNESS_LOCATION_READ))
            .addScope(new Scope(Scopes.FITNESS_NUTRITION_READ))
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    mAggregateCheckBox = (CheckBox)findViewById(R.id.aggregatecheckbox);
    mStartDateText = (TextView)findViewById(R.id.startdate);
    mEndDateText = (TextView)findViewById(R.id.enddate);
    mResultsText = (TextView)findViewById(R.id.results);

    setUpSpinnerDropDown();
    setUpListView();

}
 
開發者ID:PacktPublishing,項目名稱:Android-Sensor-Programming-By-Example,代碼行數:25,代碼來源:HistoryActivity.java

示例14: onCreate

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.subscriptiondata_layout);

    mClient = new GoogleApiClient.Builder(this)
            .addApi(Fitness.RECORDING_API)
            .addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ))
            .addScope(new Scope(Scopes.FITNESS_BODY_READ))
            .addScope(new Scope(Scopes.FITNESS_LOCATION_READ))
            .addScope(new Scope(Scopes.FITNESS_NUTRITION_READ))
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    setUpSpinnerDropDown();
    setUpListView();
}
 
開發者ID:PacktPublishing,項目名稱:Android-Sensor-Programming-By-Example,代碼行數:19,代碼來源:SubscriptionActivity.java

示例15: onCreate

import com.google.android.gms.common.api.Scope; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sensordata_layout);
    mLiveDataText = (TextView)findViewById(R.id.livedata);

    setUpSpinnerDropDown();
    setUpListView();

    mClient = new GoogleApiClient.Builder(this)
            .addApi(Fitness.SENSORS_API)
            .addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ))
            .addScope(new Scope(Scopes.FITNESS_BODY_READ))
            .addScope(new Scope(Scopes.FITNESS_LOCATION_READ))
            .addScope(new Scope(Scopes.FITNESS_NUTRITION_READ))
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}
 
開發者ID:PacktPublishing,項目名稱:Android-Sensor-Programming-By-Example,代碼行數:20,代碼來源:SensorActivity.java


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