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


Java GoogleApiClient类代码示例

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


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

示例1: initGoogleApiClient

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的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

示例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: onCreate

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  btnIncreaseCounter = (Button) findViewById(R.id.btnWearIncreaseCounter);
  btnIncreaseCounter.getBackground().setColorFilter(0xFF1194F7, PorterDuff.Mode.MULTIPLY);
  tvCounter = (TextView) findViewById(R.id.tvCounter);
  tvCounter.setText(Integer.toString(count));

  client = new GoogleApiClient.Builder(this).addApi(Wearable.API)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .build();

  btnIncreaseCounter.setOnClickListener(clickListener);
}
 
开发者ID:bevkoski,项目名称:react-native-android-wear-demo,代码行数:17,代码来源:MainActivity.java

示例4: setupGeoLocation

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
private void setupGeoLocation() {
    Log.d(TAG, "setupGeoLocation()");
    
    mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
        .addApi(LocationServices.API)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build();
    mGoogleApiClient.connect();
    
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10 * 60 * 1000);        // 10 minutes, in milliseconds
    mLocationRequest.setFastestInterval(60 * 1000);  // 60 second, in milliseconds
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // We wanto to center the Player on his actual position
    
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
    builder.addLocationRequest(mLocationRequest);
    builder.setAlwaysShow(true); // "This app wants to change your device settings for GPS location"
    mLocationSettingsRequest = builder.build();
}
 
开发者ID:stefanonicolai,项目名称:AstronomyTourPadova,代码行数:21,代码来源:GmapFragment.java

示例5: delete

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
public PendingResult<DeleteSnapshotResult> delete(GoogleApiClient googleApiClient,
                                                  final SnapshotMetadata snapshotMetadata) {
    if (!isAlreadyOpen(snapshotMetadata.getUniqueName()) &&
            !isAlreadyClosing(snapshotMetadata.getUniqueName())) {
        setIsClosing(snapshotMetadata.getUniqueName());
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.delete(googleApiClient, snapshotMetadata),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            // deleted files are closed.
                            setClosed(snapshotMetadata.getUniqueName());
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshotMetadata.getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshotMetadata.getUniqueName() +
                " is either open or is busy");
    }
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:26,代码来源:SnapshotCoordinator.java

示例6: onCreate

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBundle = savedInstanceState;
    if (getArguments() != null) {
        proyectos = getArguments().getParcelableArrayList(ARG_PROYECTOS);
    }
    //Para localizar al usuario inicializo la variable de la API de Google Maps
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(getContext())
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:17,代码来源:FragmentMapa.java

示例7: ClearAccount

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
public void ClearAccount(){
    Log.i(TAG, "Clearing Google API Account");
    GoogleApiClient mAPI = getGoogleApiClient();
    if (mAPI != null) {
        if(mAPI.isConnected()){
            mAPI.clearDefaultAccountAndReconnect();
            Log.i(TAG, "Clear account and reconnect called");
        } else {
            Log.w(TAG, "Google API client not connected when attempting disconnect");
            Toast.makeText(this, "Google API not connected. Make sure WiFi is On.", Toast.LENGTH_LONG).show();
        }
    } else {
        Log.w(TAG, "Google API was null when attempting to disconnect account");
    }
    stopSelf(mStartID);
}
 
开发者ID:etsy,项目名称:divertsy-client,代码行数:17,代码来源:SyncToDriveService.java

示例8: onCreate

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

  // Create the Google Api Client with access to Games
  mGoogleApiClient = new GoogleApiClient.Builder(this)
      .addConnectionCallbacks(this)
      .addOnConnectionFailedListener(this)
      .addApi(Games.API).addScope(Games.SCOPE_GAMES)
      .build();

  // set up a click listener for everything we care about
  for (int id : CLICKABLES) {
    findViewById(id).setOnClickListener(this);
  }
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:18,代码来源:Example.java

示例9: 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

示例10: onCreate

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
      .requestEmail()
      .build();
  mGoogleApiClient = new GoogleApiClient.Builder(this)
      .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
      .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
      .build();
  initUI();
  if (loginViewModel.isLogin()) {
    showProgress(true);
    Single.timer(1, TimeUnit.SECONDS)
        .subscribeOn(Schedulers.newThread())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(s -> {
          finish();
          startActivity(new Intent(LoginActivity.this, AppArchNavigationDrawer.class));
        });
  } else {
    loginView();
  }
}
 
开发者ID:charlesng,项目名称:SampleAppArch,代码行数:25,代码来源:LoginActivity.java

示例11: onCreate

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ButterKnife.bind(this);

    // Create an instance of GoogleAPIClient.
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
    }
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:17,代码来源:MainActivity.java

示例12: setDevice

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
private void setDevice(CastDevice device) {
    mSelectedCastDevice = device;
    mDeviceName = mSelectedCastDevice.getFriendlyName();

    if (mApiClient == null) {
        LOGD(TAG, "acquiring a connection to Google Play services for " + mSelectedCastDevice);
        Cast.CastOptions.Builder apiOptionsBuilder = getCastOptionBuilder(mSelectedCastDevice);
        mApiClient = new GoogleApiClient.Builder(mContext)
                .addApi(Cast.API, apiOptionsBuilder.build())
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
        mApiClient.connect();
    } else if (!mApiClient.isConnected() && !mApiClient.isConnecting()) {
        mApiClient.connect();
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:18,代码来源:BaseCastManager.java

示例13: initView

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
private void initView()
{
    fragmentAlert =new Fragment_display_alertes();
    fragmentMeasures=new Fragment_display_measures();
    fragmentSettings =new Fragment_display_settings();


    //add the fragment to the fragment manager
    getSupportFragmentManager().beginTransaction().add(R.id.main_container,fragmentAlert,"alertFrag").commit();
    getSupportFragmentManager().beginTransaction().add(R.id.main_container,fragmentMeasures,"measureFrag").commit();
    getSupportFragmentManager().beginTransaction().add(R.id.main_container,fragmentSettings,"settingsFrag").commit();


    //INIT the googe client
    googleClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:22,代码来源:Home_activity.java

示例14: onCreate

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.teacher_gradingfactor_activity_midterm);
    try {
        subject = subjectService.getSubjectById(getIntent().getExtras().getLong("subjectId"));
        formula = formulaService.getFormulaById(getIntent().getExtras().getLong("formulaId"));
        teacher = new TeacherHelper(this).loadUser().get();
        isExist = getIntent().getExtras().getBoolean("isExist");

        init();

        ArrayAdapter<String> spinnerAdapter =
                new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, values);
        spinnerm.setAdapter(spinnerAdapter);

    } catch (Exception e) {
        e.printStackTrace();
    }

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
 
开发者ID:inteliedoit,项目名称:thesis-project,代码行数:25,代码来源:CriteriaMidtermInputActivity.java

示例15: onCreate

import com.google.android.gms.common.api.GoogleApiClient; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Urbino.instance().getAppGraph().inject(this);
    signinPresenter.attachView(this);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestProfile()
            .build();

    googleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this::onFailApiClientFail)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    signInButton.setSize(SignInButton.SIZE_STANDARD);
    signInButton.setOnClickListener(this::onSignInClick);

}
 
开发者ID:oragamihawk,项目名称:OpenOrbitCNCAndroidFrontend,代码行数:21,代码来源:SigninActivity.java


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