Example usage for android.content Context BIND_AUTO_CREATE

List of usage examples for android.content Context BIND_AUTO_CREATE

Introduction

In this page you can find the example usage for android.content Context BIND_AUTO_CREATE.

Prototype

int BIND_AUTO_CREATE

To view the source code for android.content Context BIND_AUTO_CREATE.

Click Source Link

Document

Flag for #bindService : automatically create the service as long as the binding exists.

Usage

From source file:com.smithdtyler.prettygoodmusicplayer.NowPlaying.java

@SuppressLint("InlinedApi")
void doBindService(boolean startService) {
    Log.i(TAG, "Binding to the service!");
    bindService(new Intent(this, MusicPlaybackService.class), mConnection,
            Context.BIND_IMPORTANT | Context.BIND_AUTO_CREATE);
    mIsBound = true;/*from ww  w .ja  va  2  s . co  m*/
    // Need to start the service so it won't be stopped when this activity is destroyed.
    // https://developer.android.com/guide/components/bound-services.html
    if (startService) {
        startService(new Intent(this, MusicPlaybackService.class));
    }
}

From source file:net.networksaremadeofstring.rhybudd.ViewZenossDeviceListFragment.java

void doBindService() {
    try {//from   w  ww  .  j  av a 2  s  .  co  m
        getActivity().bindService(new Intent(getActivity(), ZenossPoller.class), mConnection,
                Context.BIND_AUTO_CREATE);
        mBound = true;
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossDeviceListFragment", "doBindService", e);
    }
}

From source file:com.mjhram.geodata.GpsMainActivity.java

/**
 * Starts the service and binds the activity to it.
 *//*w ww  .jav a 2  s.  c o  m*/
private void StartAndBindService() {
    serviceIntent = new Intent(this, GpsLoggingService.class);
    // Start the service in case it isn't already running
    //serviceIntent.putExtra("availabilityState",GetUserSelectedNavigationItem());
    startService(serviceIntent);
    // Now bind to service
    bindService(serviceIntent, gpsServiceConnection, Context.BIND_AUTO_CREATE);
    Session.setBoundToService(true);
}

From source file:com.abplus.surroundcalc.billing.BillingHelper.java

/**
 * Starts the setup process. This will start up the setup process asynchronously.
 * You will be notified through the listener when the setup process is complete.
 * This method is safe to call from a UI thread.
 *
 * @param listener The listener to notify when the setup process is complete.
 *///from  ww  w .  j  a va 2  s  . c  o  m
public void startSetup(final OnSetupFinishedListener listener) {
    if (connection == null) {
        connection = new Connection(listener);
        Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");

        if (!context.getPackageManager().queryIntentServices(intent, 0).isEmpty()) {
            context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
        } else if (listener != null) {
            String message = context.getString(R.string.billing_service_unavailable);
            Result result = new Result(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, message);
            listener.onSetupFinished(result);
        }
    }
}

From source file:com.adamas.client.android.MainActivity.java

private void bindService() {
    _serviceBound = false;//from  w  ww  . j  ava  2 s .com
    Intent intent = new Intent(this, DmVpnService.class);
    //        bindService(createExplicitFromImplicitIntent(getApplicationContext(), intent), mConnection, Context.BIND_AUTO_CREATE);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    _serviceBound = true;
}

From source file:com.nordicsemi.ImageTransferDemo.MainActivity.java

private void service_init() {
    Intent bindIntent = new Intent(this, ImageTransferService.class);
    bindService(bindIntent, mServiceConnection, Context.BIND_AUTO_CREATE);

    LocalBroadcastManager.getInstance(this).registerReceiver(UARTStatusChangeReceiver,
            makeGattUpdateIntentFilter());
}

From source file:cm.aptoide.com.facebook.android.Facebook.java

/**
 * Refresh OAuth access token method. Binds to Facebook for Android
 * stand-alone application application to refresh the access token. This
 * method tries to connect to the Facebook App which will handle the
 * authentication flow, and return a new OAuth access token. This method
 * will automatically replace the old token with a new one. Note that this
 * method is asynchronous and the callback will be invoked in the original
 * calling thread (not in a background thread).
 * //from w  w  w .  jav a 2  s  . c o m
 * @param context
 *            The Android Context that will be used to bind to the Facebook
 *            RefreshToken Service
 * @param serviceListener
 *            Callback interface for notifying the calling application when
 *            the refresh request has completed or failed (can be null). In
 *            case of a success a new token can be found inside the result
 *            Bundle under Facebook.ACCESS_TOKEN key.
 * @return true if the binding to the RefreshToken Service was created
 */
public boolean extendAccessToken(Context context, ServiceListener serviceListener) {
    Intent intent = new Intent();

    intent.setClassName("com.facebook.katana", "com.facebook.katana.platform.TokenRefreshService");

    // Verify that the application whose package name is
    // com.facebook.katana
    // has the expected FB app signature.
    if (!validateServiceIntent(context, intent)) {
        return false;
    }

    return context.bindService(intent, new TokenRefreshServiceConnection(context, serviceListener),
            Context.BIND_AUTO_CREATE);
}

From source file:com.rks.musicx.ui.activities.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (!mService) {
        Intent intent = new Intent(this, MusicXService.class);
        bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
        startService(intent);//from   w  w w.  java  2  s . c  om
        /*IntentFilter filter = new IntentFilter();
        filter.addAction(META_CHANGED);
        filter.addAction(PLAYSTATE_CHANGED);
        filter.addAction(POSITION_CHANGED);
        filter.addAction(ITEM_ADDED);
        filter.addAction(ORDER_CHANGED);
        registerReceiver(broadcastReceiver, filter);*/
    } else {
        if (musicXService != null) {
            PlayingView();
        }
    }
    Glide.get(this).clearMemory();
}

From source file:com.android.gallery3d.ingest.IngestActivity.java

private void doBindHelperService() {
    bindService(new Intent(getApplicationContext(), IngestService.class), mHelperServiceConnection,
            Context.BIND_AUTO_CREATE);
}

From source file:com.aegiswallet.actions.MainActivity.java

@Override
protected void onResume() {
    super.onResume();

    mDrawerLayout.closeDrawer(Gravity.LEFT);

    checkIfAppInitiated();/*from w  ww  .j av a 2  s .co  m*/

    nfcEnabled = prefs.contains(Constants.SHAMIR_ENCRYPTED_KEY) ? false : true;

    updateMainViews();
    doDrawerSetup();
    registerReceiver(receiver, new IntentFilter(PeerBlockchainService.ACTION_BLOCKCHAIN_STATE));
    checkBackupDone();

    String message = getIntent().getStringExtra("message");
    if (message != null) {
        Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        getIntent().removeExtra("message");
    }

    isServiceBound = this.bindService(new Intent(this, PeerBlockchainService.class),
            blockchainServiceConnection, Context.BIND_AUTO_CREATE);
    handlePendingTransactions();
    sendMessagesToWear();
    doBackupReminder();

}