_googleApiClient = new GoogleApiClient.Builder(MainActivity.this) .enableAutoManage(MainActivity.this, new GoogleApiClient.OnConnectionFailedListener() { @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { .addApi(GOOGLE_SIGN_IN_API, gso) .build();
mGoogleApiClient = new GoogleApiClient .Builder( this ) .enableAutoManage( this, 0, this ) .addApi( Places.GEO_DATA_API ) .addApi( Places.PLACE_DETECTION_API ) .addConnectionCallbacks( this ) .addOnConnectionFailedListener( this ) .build();
private void init(){ Log.d(TAG, "init: initializing"); mGoogleApiClient = new GoogleApiClient .Builder(this) .addApi(Places.GEO_DATA_API) .addApi(Places.PLACE_DETECTION_API) .enableAutoManage(this, this) .build();
mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wallet.API, new Wallet.WalletOptions.Builder() .setEnvironment(Constants.WALLET_ENVIRONMENT) .build()) .enableAutoManage(this, this) .build();
mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, 0 /* clientId */, this) .addApi(Places.GEO_DATA_API) .build(); mAdapter = new PlaceAutocompleteAdapter(this, R.layout.google_places_search_items, mGoogleApiClient, null, null);
.build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build();
.build(); mGoogleApiClient =new GoogleApiClient.Builder(getApplicationContext()) .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() { @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { Toast.makeText(MainActivity.this,"You Got an Error",Toast.LENGTH_SHORT).show(); }).addApi(Auth.GOOGLE_SIGN_IN_API,gso).build();
.build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build();
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); storage = new SharedPreferencesStorage(this); lastLocation = storage.getLastCoordinates(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, 0 /* clientId */, this) .addApi(Places.GEO_DATA_API) .build(); // Retrieve the AutoCompleteTextView that will display Place suggestions. mAutocompleteView = (AutoCompleteTextView) findViewById(R.id.autocomplete_places); // Register a listener that receives callbacks when a suggestion has been selected mAutocompleteView.setOnItemClickListener(mAutocompleteClickListener); mAdapter = new PlaceAutocompleteAdapter(this, mGoogleApiClient, null, null); mAutocompleteView.setAdapter(mAdapter); button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Start app startOverlay(); } }); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); }
mGoogleApiClient = new GoogleApiClient .Builder( this ) .enableAutoManage( this, 0, this ) .addApi( Places.GEO_DATA_API ) .addApi( Places.PLACE_DETECTION_API ) .addConnectionCallbacks( this ) .addOnConnectionFailedListener( this ) .build();
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.DRIVE_APPFOLDER)) .requestIdToken("847235219484-rc4h5v8krng4v33trnhq744sjqfntg3a.apps.googleusercontent.com") .requestEmail() .build(); mAuth = FirebaseAuth.getInstance(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, null) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { // User is signed in Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); } else { // User is signed out Log.d(TAG, "onAuthStateChanged:signed_out"); } } }; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Construct a GoogleApiClient for the {@link Places#GEO_DATA_API} using AutoManage // functionality, which automatically sets up the API client to handle Activity lifecycle // events. If your activity does not extend FragmentActivity, make sure to call connect() // and disconnect() explicitly. mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, GOOGLE_API_CLIENT_ID /* clientId */, this) .addApi(Places.GEO_DATA_API) .addApi(Places.PLACE_DETECTION_API) .build(); setContentView(R.layout.activity_main); // Retrieve the AutoCompleteTextView that will display Place suggestions. mAutocompleteView = (AutoCompleteTextView) findViewById(R.id.autocomplete_places); // Register a listener that receives callbacks when a suggestion has been selected mAutocompleteView.setOnItemClickListener(mAutocompleteClickListener); // Retrieve the TextViews that will display details and attributions of the selected place. mPlaceDetailsText = (TextView) findViewById(R.id.place_details); mPlaceDetailsAttribution = (TextView) findViewById(R.id.place_attribution); // CurrentLocation mCurrentLocation = (Button) findViewById(R.id.btn_current_location); mCurrentLocation.setOnClickListener(mOnClickListener); // Set up the adapter that will retrieve suggestions from the Places Geo Data API that cover // the entire world. mAdapter = new PlaceAutocompleteAdapter(this, android.R.layout.simple_list_item_1, mGoogleApiClient, BOUNDS_GREATER_SYDNEY, null); mAutocompleteView.setAdapter(mAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_place_find); mTextView = (TextView) findViewById( R.id.textview ); mPredictTextView = (AutoCompleteTextView) findViewById( R.id.txtSearch); mAdapter = new AutoCompleteAdapter( this ); mPredictTextView.setAdapter( mAdapter ); mPredictTextView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { AutoCompletePlace place = (AutoCompletePlace) parent.getItemAtPosition( position ); findPlaceById( place.getId() ); } }); mGoogleApiClient = new GoogleApiClient .Builder( this ) .enableAutoManage( this, 0, this ) .addApi( Places.GEO_DATA_API ) .addApi( Places.PLACE_DETECTION_API ) .addConnectionCallbacks( this ) .addOnConnectionFailedListener( this ) .build(); } @Override
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_place_find); mTextView = (TextView) findViewById( R.id.textview ); mPredictTextView = (AutoCompleteTextView) findViewById( R.id.txtSearch); mAdapter = new AutoCompleteAdapter( this ); mPredictTextView.setAdapter( mAdapter ); mPredictTextView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { AutoCompletePlace place = (AutoCompletePlace) parent.getItemAtPosition( position ); findPlaceById( place.getId() ); } }); mGoogleApiClient = new GoogleApiClient .Builder( this ) .enableAutoManage( this, 0, this ) .addApi( Places.GEO_DATA_API ) .addApi( Places.PLACE_DETECTION_API ) .addConnectionCallbacks( this ) .addOnConnectionFailedListener( this ) .build(); } @Override
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ButterKnife.bind(this); App.addActivity(this); // Construct a GoogleApiClient for the {@link Places#GEO_DATA_API} using AutoManage // functionality, which automatically sets up the API client to handle Activity lifecycle // events. If your activity does not extend FragmentActivity, make sure to call connect() // and disconnect() explicitly. mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, GOOGLE_API_CLIENT_ID /* clientId */, this) .addApi(Places.GEO_DATA_API) .addApi(Places.PLACE_DETECTION_API) .build(); setTitle(getString(R.string.title_pick_place)); // Register a listener that receives callbacks when a suggestion has been selected mAutocompleteView.setOnItemClickListener(mAutocompleteClickListener); mCurrentLocation.setOnClickListener(mOnClickListener); // Set up the adapter that will retrieve suggestions from the Places Geo Data API that cover // the entire world. mAdapter = new GooglePlacesAdapter(this, android.R.layout.simple_list_item_1, mGoogleApiClient, BOUNDS_GREATER_SYDNEY, null); mAutocompleteView.setAdapter(mAdapter); mSwipeBackLayout = getSwipeBackLayout(); mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mActivityLaunchIntent = getActivity().getIntent(); mItemId = mActivityLaunchIntent.getIntExtra(Constants.EXTRA_ITEM_ID, 0); mMaskedWallet = mActivityLaunchIntent.getParcelableExtra(Constants.EXTRA_MASKED_WALLET); String accountName = getApplication().getAccountName(); // Set up an API client FragmentActivity fragmentActivity = getActivity(); // [START build_google_api_client] mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) .enableAutoManage(fragmentActivity, this /* onConnectionFailedListener */) .setAccountName(accountName) // optional .addApi(Wallet.API, new Wallet.WalletOptions.Builder() .setEnvironment(Constants.WALLET_ENVIRONMENT) .setTheme(WalletConstants.THEME_LIGHT) .build()) .build(); // [END build_google_api_client] }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null) { mLoginAction = args.getInt(LoginActivity.EXTRA_ACTION); } GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestScopes(new Scope(WALLET_SCOPE)) .build(); mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) .enableAutoManage(getActivity(), this) .addConnectionCallbacks(this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); }
@Test public void createApiClient_Scopes() { GoogleApiClient.Builder builder = Mockito.mock(GoogleApiClient.Builder.class); BaseRx<Object> baseRx = spy(new BaseRx<Object>(ctx, new Api[]{ Fitness.HISTORY_API}, new Scope[]{ Fitness.SCOPE_ACTIVITY_READ }) { @Override protected void handleResolutionResult(int resultCode, ConnectionResult connectionResult) {} }); doReturn(builder).when(baseRx).getApiClientBuilder(); doReturn(apiClient).when(builder).build(); BaseRx.ApiClientConnectionCallbacks callbacks = Mockito.mock(BaseRx.ApiClientConnectionCallbacks.class); assertEquals(apiClient, baseRx.createApiClient(callbacks)); verify(builder).addApi(Fitness.HISTORY_API); verify(builder).addScope(Fitness.SCOPE_ACTIVITY_READ); verify(builder).addConnectionCallbacks(callbacks); verify(builder).addOnConnectionFailedListener(callbacks); verify(callbacks).setClient(Matchers.any(GoogleApiClient.class)); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mPromoWasSelected = savedInstanceState.getBoolean(KEY_PROMO_CLICKED); } String accountName = ((BikestoreApplication) getActivity().getApplication()).getAccountName(); AddressOptions options = new AddressOptions(WalletConstants.THEME_LIGHT); mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) .addApi(Address.API, options) .setAccountName(accountName) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); }
/** * Builds {@link GoogleApiClient}, enabling automatic lifecycle management using * {@link GoogleApiClient.Builder#enableAutoManage(FragmentActivity, * int, GoogleApiClient.OnConnectionFailedListener)}. I.e., GoogleApiClient connects in * {@link AppCompatActivity#onStart} -- or if onStart() has already happened -- it connects * immediately, and disconnects automatically in {@link AppCompatActivity#onStop}. */ private synchronized void buildGoogleApiClient() { if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Nearby.MESSAGES_API, new MessagesOptions.Builder() .setPermissions(NearbyPermissions.BLE) .build()) .addConnectionCallbacks(this) .enableAutoManage(this, this) .build(); } }