当前位置: 首页>>代码示例>>Java>>正文


Java GoogleApiClient.Builder方法代码示例

本文整理汇总了Java中com.google.android.gms.common.api.GoogleApiClient.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleApiClient.Builder方法的具体用法?Java GoogleApiClient.Builder怎么用?Java GoogleApiClient.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.common.api.GoogleApiClient的用法示例。


在下文中一共展示了GoogleApiClient.Builder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
/**
 * Initializes the GoogleApiClient. Give your main AndroidLauncher as context.
 * <p>
 * Don't forget to add onActivityResult method there with call to onGpgsActivityResult.
 *
 * @param context        your AndroidLauncher class
 * @param enableDriveAPI true if you activate save gamestate feature
 * @return this for method chunking
 */
public GpgsClient initialize(Activity context, boolean enableDriveAPI) {

    if (mGoogleApiClient != null)
        throw new IllegalStateException("Already initialized.");

    myContext = context;
    // retry some times when connect fails (needed when game state sync is enabled)
    firstConnectAttempt = MAX_CONNECTFAIL_RETRIES;

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(myContext)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Games.API).addScope(Games.SCOPE_GAMES);

    driveApiEnabled = enableDriveAPI;
    if (driveApiEnabled)
        builder.addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER);

    // add other APIs and scopes here as needed

    mGoogleApiClient = builder.build();

    return this;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:34,代码来源:GpgsClient.java

示例2: createApiClientBuilder

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
/**
 * Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
 * you do not have to do this; use this method only if you need to make
 * nonstandard setup (e.g. adding extra scopes for other APIs) on the
 * GoogleApiClient.Builder before calling @link{#setup}.
 */
public GoogleApiClient.Builder createApiClientBuilder() {
    if (mSetupDone) {
        String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
                + "calling setup. You can only get a client builder BEFORE performing setup.";
        logError(error);
        throw new IllegalStateException(error);
    }

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
            mActivity, this, this);

    if (0 != (mRequestedClients & CLIENT_GAMES)) {
        builder.addApi(Games.API, mGamesApiOptions);
        builder.addScope(Games.SCOPE_GAMES);
    }

    if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
      builder.addScope(Drive.SCOPE_APPFOLDER);
      builder.addApi(Drive.API);
    }

    mGoogleApiClientBuilder = builder;
    return builder;
}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:31,代码来源:GameHelper.java

示例3: createApiClientBuilder

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
/**
 * Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
 * you do not have to do this; use this method only if you need to make
 * nonstandard setup (e.g. adding extra scopes for other APIs) on the
 * GoogleApiClient.Builder before calling @link{#setup}.
 */
public GoogleApiClient.Builder createApiClientBuilder() {
    if (mSetupDone) {
        String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
                + "calling setup. You can only get a client builder BEFORE performing setup.";
        logError(error);
        throw new IllegalStateException(error);
    }

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
            mActivity, this, this);

    if (0 != (mRequestedClients & CLIENT_GAMES)) {
        builder.addApi(Games.API, mGamesApiOptions);
        builder.addScope(Games.SCOPE_GAMES);
    }

    if (0 != (mRequestedClients & CLIENT_PLUS)) {
        builder.addApi(Plus.API);
        builder.addScope(Plus.SCOPE_PLUS_LOGIN);
    }

    if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
      builder.addScope(Drive.SCOPE_APPFOLDER);
      builder.addApi(Drive.API);
    }

    mGoogleApiClientBuilder = builder;
    return builder;
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:36,代码来源:GameHelper.java

示例4: createApiClientBuilder

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
/**
 * Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
 * you do not have to do this; use this method only if you need to make
 * nonstandard setup (e.g. adding extra scopes for other APIs) on the
 * GoogleApiClient.Builder before calling @link{#setup}.
 */
public GoogleApiClient.Builder createApiClientBuilder() {
    if (mSetupDone) {
        String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
                + "calling setup. You can only get a client builder BEFORE performing setup.";
        logError(error);
        throw new IllegalStateException(error);
    }

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
            mActivity, this, this);

    if (0 != (mRequestedClients & CLIENT_GAMES)) {
        builder.addApi(Games.API, mGamesApiOptions);
        builder.addScope(Games.SCOPE_GAMES);
    }

    if (0 != (mRequestedClients & CLIENT_PLUS)) {
        builder.addApi(Plus.API);
        builder.addScope(Plus.SCOPE_PLUS_LOGIN);
    }

    if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
        builder.addScope(Drive.SCOPE_APPFOLDER);
        builder.addApi(Drive.API);
    }

    mGoogleApiClientBuilder = builder;
    return builder;
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:36,代码来源:GameHelper.java

示例5: start

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
/** Starts the helper. Call this from your Activity's onStart(). */
public void start() {
    Activity activity = getActivity("start()");
    if (activity == null) {
        return;
    }

    if (mStarted) {
        LOGW(TAG, "Helper already started. Ignoring redundant call.");
        return;
    }

    mStarted = true;
    if (mResolving) {
        // if resolving, don't reconnect the plus client
        LOGD(TAG, "Helper ignoring signal to start because we're resolving a failure.");
        return;
    }
    LOGD(TAG, "Helper starting. Connecting " + mAccountName);
    if (mGoogleApiClient == null) {
        LOGD(TAG, "Creating client.");

        GoogleApiClient.Builder builder = new GoogleApiClient.Builder(activity);
        for (String scope : AUTH_SCOPES) {
            builder.addScope(new Scope(scope));
        }
        mGoogleApiClient = builder.addApi(Plus.API)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .setAccountName(mAccountName)
                .build();
    }
    LOGD(TAG, "Connecting client.");
    mGoogleApiClient.connect();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:36,代码来源:LoginAndAuthHelper.java

示例6: GooglePlayServices_Init

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
public void GooglePlayServices_Init()
{
	//This will start all the login flow etc
	
	if(mGoogleApiClient!=null)
	{
		Log.i("yoyo","Attempting to initialise Google Play Services when they have already been initialised.");
		return;
	}
	
	String appid = RunnerActivity.CurrentActivity.mYYPrefs.getString("com.google.android.gms.games.APP_ID");
	
	if(appid == null|| appid.isEmpty())
	{
		Log.i("yoyo", "Failed to find appid, not initialising GoogleApiClient");
		return;
		
	}
	else
		Log.i("yoyo", "Found google play app id = " + appid);
	
	
	GoogleApiClient.Builder builder = new GoogleApiClient.Builder(RunnerActivity.CurrentActivity);
	
       builder.addConnectionCallbacks(this);
	builder.addOnConnectionFailedListener(this);
	builder.addApi(Games.API);
	builder.addScope(Games.SCOPE_GAMES);
	builder.addApi(Plus.API);
	builder.addScope(Plus.SCOPE_PLUS_LOGIN);
	
	boolean bCloudEnable = RunnerActivity.CurrentActivity.mYYPrefs.getBoolean("YYGoogleCloudSavingEnabled");
	if( bCloudEnable )
	{
		//These are needed if you are using the cloud saving functionality, if you have them in & do not have save games enabled in your google developer console for your game, you won't be able to log
		// in to google play services...
		Log.i("yoyo","Adding Google Drive API for cloud saving");
		builder.addApi(Drive.API);
		builder.addScope(Drive.SCOPE_APPFOLDER);
	}
	
	
	mGoogleApiClient = builder.build();
	
}
 
开发者ID:Magicrafter13,项目名称:1946,代码行数:46,代码来源:GooglePlayServicesExtension.java

示例7: createApiClient

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
protected GoogleApiClient createApiClient(Subscriber<? super T> subscriber) {

        ApiClientConnectionCallbacks apiClientConnectionCallbacks = new ApiClientConnectionCallbacks(subscriber);

        GoogleApiClient.Builder apiClientBuilder = new GoogleApiClient.Builder(ctx);


        for (Api<? extends Api.ApiOptions.NotRequiredOptions> service : services) {
            apiClientBuilder.addApi(service);
        }

        apiClientBuilder.addConnectionCallbacks(apiClientConnectionCallbacks);
        apiClientBuilder.addOnConnectionFailedListener(apiClientConnectionCallbacks);

        GoogleApiClient apiClient = apiClientBuilder.build();

        apiClientConnectionCallbacks.setClient(apiClient);

        return apiClient;

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:BaseObservable.java

示例8: getApiClientBuilder

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
protected GoogleApiClient.Builder getApiClientBuilder() {
    return new GoogleApiClient.Builder(ctx);
}
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:4,代码来源:RxLocationBaseOnSubscribe.java

示例9: createApiClient

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
protected GoogleApiClient createApiClient(ApiClientConnectionCallbacks apiClientConnectionCallbacks) {

        GoogleApiClient.Builder apiClientBuilder = getApiClientBuilder();


        for (Api<? extends Api.ApiOptions.NotRequiredOptions> service : services) {
            apiClientBuilder.addApi(service);
        }

        if (scopes != null) {
            for (Scope scope : scopes) {
                apiClientBuilder.addScope(scope);
            }
        }

        apiClientBuilder.addConnectionCallbacks(apiClientConnectionCallbacks);
        apiClientBuilder.addOnConnectionFailedListener(apiClientConnectionCallbacks);

        GoogleApiClient apiClient = apiClientBuilder.build();

        apiClientConnectionCallbacks.setClient(apiClient);

        return apiClient;
    }
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:25,代码来源:RxLocationBaseOnSubscribe.java

示例10: modifyGoogleApiClientBuilder

import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
/**
 * Modify a GoogleApiClient.Builder as necessary for doing Physical Web scanning.
 * @param builder The builder to be modified.
 * @return The Builder.
 */
GoogleApiClient.Builder modifyGoogleApiClientBuilder(GoogleApiClient.Builder builder) {
    return builder.addApi(Nearby.MESSAGES_API);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:9,代码来源:PhysicalWebBleClient.java


注:本文中的com.google.android.gms.common.api.GoogleApiClient.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。