当前位置: 首页>>代码示例>>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;未经允许,请勿转载。