本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例8: getApiClientBuilder
import com.google.android.gms.common.api.GoogleApiClient; //导入方法依赖的package包/类
protected GoogleApiClient.Builder getApiClientBuilder() {
return new GoogleApiClient.Builder(ctx);
}
示例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;
}
示例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);
}