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