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


Java Scopes類代碼示例

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


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

示例1: LoginGoogle

import com.google.android.gms.common.Scopes; //導入依賴的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: init

import com.google.android.gms.common.Scopes; //導入依賴的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

示例3: loginGoogleAPI

import com.google.android.gms.common.Scopes; //導入依賴的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

示例4: createConnection

import com.google.android.gms.common.Scopes; //導入依賴的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

示例5: testLoginGoogleSuccess

import com.google.android.gms.common.Scopes; //導入依賴的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

示例6: testLoginGoogleCancel

import com.google.android.gms.common.Scopes; //導入依賴的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

示例7: testLoginGoogleError

import com.google.android.gms.common.Scopes; //導入依賴的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

示例8: testLoginGoogleConnectionError

import com.google.android.gms.common.Scopes; //導入依賴的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

示例9: onCreate

import com.google.android.gms.common.Scopes; //導入依賴的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

示例10: onCreate

import com.google.android.gms.common.Scopes; //導入依賴的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

示例11: onCreate

import com.google.android.gms.common.Scopes; //導入依賴的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

示例12: onCreate

import com.google.android.gms.common.Scopes; //導入依賴的package包/類
@Override
public void onCreate() {
	super.onCreate();
	googleApiClient = new GoogleApiClient.Builder(this)
			.addApi(Plus.API)
			.addApi(Fitness.SENSORS_API)
			.addApi(Fitness.SESSIONS_API)
			.addApi(Fitness.HISTORY_API)
			.addApi(Fitness.RECORDING_API)
			.addApi(LocationServices.API)
			.addScope(new Scope(Scopes.PROFILE))
			.addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
			.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
			.addConnectionCallbacks(connectionListenerAdapter)
			.addOnConnectionFailedListener(connectionListenerAdapter)
			.build();
}
 
開發者ID:FauDroids,項目名稱:KeepOn,代碼行數:18,代碼來源:GoogleApiClientService.java

示例13: rxAction

import com.google.android.gms.common.Scopes; //導入依賴的package包/類
@Override
public void rxAction(int requestCode) {
    Assert.assertEquals(requestCode, ActivityResponses.GET_LOGINTOKEN);
    final Activity activity = (Activity) getContext();
    final String[] permissions = new String[]{Manifest.permission.GET_ACCOUNTS};

    final Scope[] scopes = {new Scope(Scopes.PROFILE), new Scope(Scopes.EMAIL)};

    // NB : Rationale is optional and can be null
    final SnackbarRationaleOperator rationaleOperator = new SnackbarRationaleOperator(this, "Need permission for ...");

    getLoginToken(activity, permissions, scopes, rationaleOperator)
            .subscribe(new Consumer<String>() {
                @Override
                public void accept(String s) {
                    Toast.makeText(getContext(), "Token is : " + s, Toast.LENGTH_SHORT).show();
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) {
                    Toast.makeText(getContext(), "Exception : " + throwable, Toast.LENGTH_SHORT).show();
                }
            });
}
 
開發者ID:finn-no,項目名稱:rxactivityresponse,代碼行數:25,代碼來源:CustomStateObserverExampleButton.java

示例14: buildFitnessClient

import com.google.android.gms.common.Scopes; //導入依賴的package包/類
/**
 *  Build a {@link GoogleApiClient} that will authenticate the user and allow the application
 *  to connect to Fitness APIs. The scopes included should match the scopes your app needs
 *  (see documentation for details). Authentication will occasionally fail intentionally,
 *  and in those cases, there will be a known resolution, which the OnConnectionFailedListener()
 *  can address. Examples of this include the user never having signed in before, or
 *  having multiple accounts on the device and needing to specify which account to use, etc.
 */
private void buildFitnessClient(final Context context) {
    if (context != null) {
        Log.i(TAG, "Creating the Google API Client with context: " + context.getClass().getName());
        // Create the Google API Client
        mClient = new GoogleApiClient.Builder(context)
                .addApiIfAvailable(Plus.API)
                .addApiIfAvailable(Fitness.SENSORS_API)
                .addApi(Fitness.SESSIONS_API)
                .addApi(Fitness.HISTORY_API)
                .addApi(Fitness.RECORDING_API)
                //.addApi(LocationServices.API)
                .addScope(new Scope(Scopes.PROFILE))
                //.addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
                .addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }

}
 
開發者ID:blackcj,項目名稱:GoogleFitExample,代碼行數:29,代碼來源:DataManager.java

示例15: login

import com.google.android.gms.common.Scopes; //導入依賴的package包/類
@Override
public void login(Activity activity) {
    mActivity = activity;
    mRequestMap = new HashMap<>();
    mSettingsManager = new SettingsManager(activity);

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

    if(mGoogleApiClient != null) {
        mGoogleApiClient.connect();
    }
}
 
開發者ID:mklschreiber,項目名稱:Crowdi,代碼行數:21,代碼來源:GooglePortal.java


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