當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。