com.google.android.gms.common.api.GoogleApiClient Java Examples

The following examples show how to use com.google.android.gms.common.api.GoogleApiClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UtilityService.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
/**
 * Add geofences using Play Services
 */
private void addGeofencesInternal() {
    Log.v(TAG, ACTION_ADD_GEOFENCES);
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .build();

    // It's OK to use blockingConnect() here as we are running in an
    // IntentService that executes work on a separate (background) thread.
    ConnectionResult connectionResult = googleApiClient.blockingConnect(
            Constants.GOOGLE_API_CLIENT_TIMEOUT_S, TimeUnit.SECONDS);

    if (connectionResult.isSuccess() && googleApiClient.isConnected()) {
        PendingIntent pendingIntent = PendingIntent.getBroadcast(
                this, 0, new Intent(this, UtilityReceiver.class), 0);
        GeofencingApi.addGeofences(googleApiClient,
                TouristAttractions.getGeofenceList(), pendingIntent);
        googleApiClient.disconnect();
    } else {
        Log.e(TAG, String.format(Constants.GOOGLE_API_CLIENT_ERROR_MSG,
                connectionResult.getErrorCode()));
    }
}
 
Example #2
Source File: EasyFirebaseAuth.java    From EasyFirebase with Apache License 2.0 6 votes vote down vote up
public EasyFirebaseAuth(GoogleApiClient googleApiClient) {
    mAuth = FirebaseAuth.getInstance();
    this.googleApiClient = googleApiClient;

    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            final FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                if (firebaseUserSubscriber != null) {
                    firebaseUserSubscriber.onNext(new Pair<GoogleSignInAccount, FirebaseUser>(googleSignInAccount, user));
                    firebaseUserSubscriber.onCompleted();
                }
                if (loggedSubcriber != null) {
                    loggedSubcriber.onNext(user);
                }
                // User is signed in
                Log.d("TAG", "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                Log.d("TAG", "onAuthStateChanged:signed_out");
            }
        }
    };
}
 
Example #3
Source File: MainActivity.java    From android-Geofencing with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Rather than displayng this activity, simply display a toast indicating that the geofence
    // service is being created. This should happen in less than a second.
    if (!isGooglePlayServicesAvailable()) {
        Log.e(TAG, "Google Play services unavailable.");
        finish();
        return;
    }

    mApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    mApiClient.connect();

    // Instantiate a new geofence storage area.
    mGeofenceStorage = new SimpleGeofenceStore(this);
    // Instantiate the current List of geofences.
    mGeofenceList = new ArrayList<Geofence>();
    createGeofences();
}
 
Example #4
Source File: BaseActivity.java    From attendee-checkin with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Google+ Sign in
    mApiClient = new GoogleApiClient.Builder(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .addScope(Plus.SCOPE_PLUS_PROFILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    mConnectionProgressDialog = new ProgressDialog(this);
    mConnectionProgressDialog.setMessage(getString(R.string.signing_in));
    GutenbergApplication app = GutenbergApplication.from(this);
    if (!app.isUserLoggedIn()) {
        selectAccount(false);
    } else {
        app.requestSync(false);
    }
    adjustTaskDescription();
}
 
Example #5
Source File: GoogleDriveClient.java    From financisto with GNU General Public License v2.0 6 votes vote down vote up
private ConnectionResult connect() throws ImportExportException {
    if (googleApiClient == null) {
        String googleDriveAccount = MyPreferences.getGoogleDriveAccount(context);
        if (googleDriveAccount == null) {
            throw new ImportExportException(R.string.google_drive_account_required);
        }
        googleApiClient = new GoogleApiClient.Builder(context)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .setAccountName(googleDriveAccount)
                //.addConnectionCallbacks(this)
                //.addOnConnectionFailedListener(this)
                .build();
    }
    return googleApiClient.blockingConnect(1, TimeUnit.MINUTES);
}
 
Example #6
Source File: QuizReportActionService.java    From android-Quiz with Apache License 2.0 6 votes vote down vote up
@Override
public void onHandleIntent(Intent intent) {
    if (intent.getAction().equals(ACTION_RESET_QUIZ)) {
        final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Wearable.API)
                .build();
        ConnectionResult result = googleApiClient.blockingConnect(CONNECT_TIMEOUT_MS,
                TimeUnit.MILLISECONDS);
        if (!result.isSuccess()) {
            Log.e(TAG, "QuizReportActionService failed to connect to GoogleApiClient.");
            return;
        }

        CapabilityApi.GetCapabilityResult capabilityResult = Wearable.CapabilityApi
                .getCapability(googleApiClient, RESET_QUIZ_CAPABILITY_NAME,
                        CapabilityApi.FILTER_REACHABLE)
                .await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS);
        if (capabilityResult.getStatus().isSuccess()) {
            sendResetMessage(googleApiClient, capabilityResult.getCapability());
        } else {
            Log.e(TAG, "Failed to get capabilities, status: "
                    + capabilityResult.getStatus().getStatusMessage());
        }
    }
}
 
Example #7
Source File: LocatrFragment.java    From AndroidProgramming3e with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    mClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(@Nullable Bundle bundle) {
                    getActivity().invalidateOptionsMenu();
                }

                @Override
                public void onConnectionSuspended(int i) {

                }
            })
            .build();
}
 
Example #8
Source File: DeviceClient.java    From wearabird with MIT License 6 votes vote down vote up
public void sendSensorData(final int sensorType, final int accuracy, final long timestamp, final float[] values) {
	ConnectionManager.getInstance(context).sendMessage(new ConnectionManager.ConnectionManagerRunnable(context) {
		@Override
		public void send(GoogleApiClient googleApiClient) {
			PutDataMapRequest dataMap = PutDataMapRequest.create("/sensors/" + sensorType);

			dataMap.getDataMap().putInt(DataMapKeys.ACCURACY, accuracy);
			dataMap.getDataMap().putLong(DataMapKeys.TIMESTAMP, timestamp);
			dataMap.getDataMap().putFloatArray(DataMapKeys.VALUES, values);

			PutDataRequest putDataRequest = dataMap.asPutDataRequest();

			Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
		}
	});
}
 
Example #9
Source File: GoogleApiHelper.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
public static GoogleApiClient createGoogleApiClient(FragmentActivity fragmentActivity) {
    GoogleApiClient.OnConnectionFailedListener failedListener;

    if (fragmentActivity instanceof GoogleApiClient.OnConnectionFailedListener) {
        failedListener = (GoogleApiClient.OnConnectionFailedListener) fragmentActivity;
    } else {
        throw new IllegalArgumentException(fragmentActivity.getClass().getSimpleName() + " should implement OnConnectionFailedListener");
    }

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(fragmentActivity.getResources().getString(R.string.google_web_client_id))
            .requestEmail()
            .build();

    return new GoogleApiClient.Builder(fragmentActivity)
            .enableAutoManage(fragmentActivity, failedListener)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
}
 
Example #10
Source File: MyCurrentLocation.java    From augmented-reality-example with GNU General Public License v2.0 5 votes vote down vote up
protected synchronized void buildGoogleApiClient(Context context) {
    mGoogleApiClient = new GoogleApiClient.Builder(context)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();

    mLocationRequest = LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
            .setInterval(10 * 1000)        // 10 seconds, in milliseconds
            .setFastestInterval(1 * 1000); // 1 second, in milliseconds
}
 
Example #11
Source File: BraintreeFragment.java    From braintree_android with MIT License 5 votes vote down vote up
protected GoogleApiClient getGoogleApiClient() {
    if (getActivity() == null) {
        postCallback(new GoogleApiClientException(ErrorType.NotAttachedToActivity, 1));
        return null;
    }

    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                .addApi(Wallet.API, new Wallet.WalletOptions.Builder()
                        .setEnvironment(GooglePayment.getEnvironment(getConfiguration().getGooglePayment()))
                        .setTheme(WalletConstants.THEME_LIGHT)
                        .build())
                .build();
    }

    if (!mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) {
        mGoogleApiClient.registerConnectionCallbacks(new ConnectionCallbacks() {
            @Override
            public void onConnected(Bundle bundle) {}

            @Override
            public void onConnectionSuspended(int i) {
                postCallback(new GoogleApiClientException(ErrorType.ConnectionSuspended, i));
            }
        });

        mGoogleApiClient.registerConnectionFailedListener(new OnConnectionFailedListener() {
            @Override
            public void onConnectionFailed(ConnectionResult connectionResult) {
                postCallback(new GoogleApiClientException(ErrorType.ConnectionFailed, connectionResult.getErrorCode()));
            }
        });

        mGoogleApiClient.connect();
    }

    return mGoogleApiClient;
}
 
Example #12
Source File: SnapshotCoordinator.java    From Asteroid with Apache License 2.0 5 votes vote down vote up
@Override
public PendingResult<OpenSnapshotResult> resolveConflict(GoogleApiClient googleApiClient,
                                                         String conflictId, String snapshotId,
                                                         SnapshotMetadataChange snapshotMetadataChange,
                                                         SnapshotContents snapshotContents) {

    // Since the unique name of the snapshot is unknown, this resolution method cannot be safely
    // used.  Please use another method of resolution.
    throw new IllegalStateException("resolving conflicts with ids is not supported.");
}
 
Example #13
Source File: UARTConfigurationsActivity.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list);

	// Check if the WEAR device is connected to the UART device itself, or by the phone.
	// Binding will fail if we are using phone as proxy as the service has not been started before.
	final Intent service = new Intent(this, BleProfileService.class);
	bindService(service, serviceConnection, 0);

	final WearableListView listView = findViewById(R.id.list);
	listView.setClickListener(this);
	listView.setAdapter(adapter = new UARTConfigurationsAdapter(this));

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


	// Register the broadcast receiver that will listen for events from the device
	final IntentFilter filter = new IntentFilter();
	filter.addAction(BleProfileService.BROADCAST_CONNECTION_STATE);
	filter.addAction(BleProfileService.BROADCAST_ERROR);
	LocalBroadcastManager.getInstance(this).registerReceiver(serviceBroadcastReceiver, filter);
}
 
Example #14
Source File: CrashReport.java    From AndroidWearCrashReport with Apache License 2.0 5 votes vote down vote up
private CrashReport(Context context) {
    this.context = context;
    //Init the Google API client ot listen to crashes
    mGoogleApiClient = new GoogleApiClient.Builder(context)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    mGoogleApiClient.connect();
}
 
Example #15
Source File: GoogleLocationUpdatesProvider.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionSuspended(int i) {
    if (i == GoogleApiClient.ConnectionCallbacks.CAUSE_NETWORK_LOST) {
        Logging.debug(LOG_TAG + "Connection lost. Cause: Network Lost.");
    } else if (i == GoogleApiClient.ConnectionCallbacks.CAUSE_SERVICE_DISCONNECTED) {
        Logging.debug(LOG_TAG + "Connection lost. Cause: Service Disconnected");
    }
}
 
Example #16
Source File: GoogleLastLocationProvider.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
@Override
protected void provide() {
    mGoogleApiClient = new GoogleApiClient.Builder(getContext())
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    if (!mGoogleApiClient.isConnected()) {
        mGoogleApiClient.connect();
    }
}
 
Example #17
Source File: MapsActivity.java    From Krishi-Seva with MIT License 5 votes vote down vote up
protected synchronized void buildGoogleApiClient() {
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
    mGoogleApiClient.connect();
}
 
Example #18
Source File: MapLoadFragment.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
private void buildGoogleApiClient() {
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }
}
 
Example #19
Source File: Google.java    From easygoogle with Apache License 2.0 5 votes vote down vote up
/**
 * Get the underlying <code>GoogleApiClient</code> instance to access public methods. If GoogleApiClient is not
 * properly created, there will be a warning in logcat.
 * @return the underlying GoogleApiClient instance.
 */
public GoogleApiClient getGoogleApiClient() {
    GoogleApiClient googleApiClient = mGacFragment.getGoogleApiClient();
    if (googleApiClient == null) {
        Log.w(TAG, "GoogleApiClient is not created, getGoogleApiClient() returning null.");
    }

    return googleApiClient;
}
 
Example #20
Source File: ProcessAPKChannelDownload.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
static synchronized void enqueueWork(final GoogleApiClient client, final Channel current_channel) {
    UserError.Log.d(TAG, "EnqueueWork enter");
    if (client == null || current_channel == null) {
        UserError.Log.d(TAG, "Enqueue Work: Null input data!!");
        return;
    }
    googleApiClient = client;
    channel = current_channel;
    enqueueWork(xdrip.getAppContext(), ProcessAPKChannelDownload.class, Constants.APK_DOWNLOAD_JOB_ID, new Intent());
}
 
Example #21
Source File: RequestListenerService.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessageReceived(final MessageEvent event) {
  Log.i("Test", "Received message!");
  // When a message is received, build a Google API client and connect it
  // The Wearable API is used for communicating with the Wear device, and the
  // Location API is used when collecting a new feature
  final GoogleApiClient client = new GoogleApiClient.Builder(this)
          .addApi(Wearable.API)
          .addApi(LocationServices.API)
          .build();
  ConnectionResult connectionResult = client.blockingConnect(30, TimeUnit.SECONDS);
  if (!connectionResult.isSuccess()) {
    Log.e("Test", "Failed to connect to GoogleApiClient");
  }
  Log.i("Test", "Successfully connected to Google Api Service");
  // Get the path of the message and handle it appropriately
  String path = event.getPath();
  switch(path) {
    case LAYER_REQUEST:
      handleLayerRequest(event, client);
      break;
    case FEATURE_TYPE_REQUEST:
      handleFeatureTypeRequest(event, client);
      break;
    case FEATURE_TYPE_RESPONSE:
      handleFeatureTypeResponse(event, client);
      break;
  }
}
 
Example #22
Source File: AwarenessMotionUpdatesProvider.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
@Override
    protected void provide() {
        Thread thread = Thread.currentThread();
        Thread.UncaughtExceptionHandler wrapped = thread.getUncaughtExceptionHandler();
        if (!(wrapped instanceof GoogleApiFixUncaughtExceptionHandler)) {
            GoogleApiFixUncaughtExceptionHandler handler = new GoogleApiFixUncaughtExceptionHandler(wrapped);
            thread.setUncaughtExceptionHandler(handler);
        }
//        Thread thread = Thread.currentThread();
//        thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
//            @Override
//            public void uncaughtException(Thread thread, Throwable throwable) {
//                System.out.println(thread.getName() + " throws exception: " + throwable);
//            }
//        });

            client = new GoogleApiClient.Builder(getContext())                              //Establish Connection
                    .addApi(Awareness.API)
                    .build();
            client.connect();
            walkingFence = DetectedActivityFence.during(DetectedActivityFence.WALKING);     //Create Fence
            onFootFence = DetectedActivityFence.during(DetectedActivityFence.ON_FOOT);
            runningFence = DetectedActivityFence.during(DetectedActivityFence.RUNNING);

            intent = new Intent(FENCE_RECEIVER_ACTION);                                     //Set up the intent and intent filter
            myFillter = new IntentFilter(FENCE_RECEIVER_ACTION);
            myPendingIntent = PendingIntent.getBroadcast(getContext(), 0, intent, 0);           //Set up the pendingIntent
            myFenceReceiver = new FenceReceiver();                                              //Set up the receiver
            getContext().registerReceiver(myFenceReceiver, myFillter);
            registerFence(WALKINGFENCE, walkingFence);                                       //register the fences
            registerFence(TILTINGFENCE, tiltingFence);
            registerFence(ONFOOTFENCE, onFootFence);
            registerFence(RUNNINGFENCE, runningFence);
    }
 
Example #23
Source File: SelectLocationActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
private void buildGoogleApiClient() {
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}
 
Example #24
Source File: GameHelper.java    From ColorPhun with Apache License 2.0 5 votes vote down vote up
/**
 * 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_APPSTATE)) {
        builder.addApi(AppStateManager.API);
        builder.addScope(AppStateManager.SCOPE_APP_STATE);
    }

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

    mGoogleApiClientBuilder = builder;
    return builder;
}
 
Example #25
Source File: ActivityRequestUpdatesSingleOnSubscribe.java    From RxGps with Apache License 2.0 5 votes vote down vote up
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter<Status> emitter) {
    //noinspection MissingPermission
    setupLocationPendingResult(
            ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(apiClient, detectionIntervalMillis, pendingIntent),
            SingleResultCallBack.get(emitter)
    );
}
 
Example #26
Source File: GoogleImpl.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void nativelogin() {
    //if(!checkForPermission(Manifest.permission.GET_ACCOUNTS, "This is required to login with Google+")) {
    //    return;
    //}
    getClient(new SuccessCallback<GoogleApiClient>() {

        @Override
        public void onSucess(GoogleApiClient client) {
            nativeLoginImpl(client);
        }
        
    });
    
}
 
Example #27
Source File: SyncAdapter.java    From attendee-checkin with Apache License 2.0 5 votes vote down vote up
public SyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
    super(context, autoInitialize, allowParallelSyncs);
    mApiClient = new GoogleApiClient.Builder(context)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .addScope(Plus.SCOPE_PLUS_PROFILE)
            .build();
}
 
Example #28
Source File: RegistrationIntentService.java    From friendlyping with Apache License 2.0 5 votes vote down vote up
/**
 * Sends the registration to the server.
 *
 * @param token The token to send.
 * @throws IOException Thrown when a connection issue occurs.
 */
private void sendRegistrationToServer(String token) throws IOException {
    final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_PROFILE)
            .build();
    googleApiClient.blockingConnect();

    Bundle registration = createRegistrationBundle(googleApiClient);
    registration.putString(PingerKeys.REGISTRATION_TOKEN, token);

    // Register the user at the server.
    GoogleCloudMessaging.getInstance(this).send(FriendlyPingUtil.getServerUrl(this),
            String.valueOf(System.currentTimeMillis()), registration);
}
 
Example #29
Source File: SetTimerActivity.java    From AndroidWearable-Samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int paramLength = getIntent().getIntExtra(AlarmClock.EXTRA_LENGTH, 0);
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "SetTimerActivity:onCreate=" + paramLength);
    }
    if (paramLength > 0 && paramLength <= 86400) {
        long durationMillis = paramLength * 1000;
        setupTimer(durationMillis);
        finish();
        return;
    }

    Resources res = getResources();
    for (int i = 0; i < NUMBER_OF_TIMES; i++) {
        mTimeOptions[i] = new ListViewItem(
                res.getQuantityString(R.plurals.timer_minutes, i + 1, i + 1),
                (i + 1) * 60 * 1000);
    }

    setContentView(R.layout.timer_set_timer);

    // Initialize a simple list of countdown time options.
    mListView = (ListView) findViewById(R.id.times_list_view);
    ArrayAdapter<ListViewItem> arrayAdapter = new ArrayAdapter<ListViewItem>(this,
            android.R.layout.simple_list_item_1, mTimeOptions);
    mListView.setAdapter(arrayAdapter);
    mListView.setOnItemClickListener(this);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}
 
Example #30
Source File: LogoutHelper.java    From social-app-android with Apache License 2.0 5 votes vote down vote up
private static void logoutByProvider(String providerId, GoogleApiClient mGoogleApiClient, FragmentActivity fragmentActivity) {
    switch (providerId) {
        case GoogleAuthProvider.PROVIDER_ID:
            logoutGoogle(mGoogleApiClient, fragmentActivity);
            break;

        case FacebookAuthProvider.PROVIDER_ID:
            logoutFacebook(fragmentActivity.getApplicationContext());
            break;
    }
}