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:jp.co.rediscovery.arflight.ManagerFragment.java

/***
 * ARSDK????/*from  w ww . j  a va  2s .c  o  m*/
 * #startDiscovery???
 */
private void bindServices() {
    if (discoveryServiceBinder == null) {
        final Context app = getActivity().getApplicationContext();
        final Intent intent = new Intent(app, ARDiscoveryService.class);
        app.bindService(intent, ardiscoveryServiceConnection, Context.BIND_AUTO_CREATE);
    } else if (!ardiscoveryServiceBound) {
        ardiscoveryService = ((ARDiscoveryService.LocalBinder) discoveryServiceBinder).getService();
        ardiscoveryServiceBound = true;

        ardiscoveryService.start();
    }
}

From source file:com.smp.musicspeed.MainActivity.java

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

    if (adView != null) {
        adView.resume();/*  w  ww. j a  va2s  .c  o m*/
    }
    if (service != null) {
        stopServiceForeground();
        setPlayImage();

        /*
         * if (service.hasVisualizer()) service.setVisualizerEnabled(true);
         */
    }
    if (!interstitial.isLoaded()) {
        AdRequest adRequest = new AdRequest.Builder().addTestDevice(TEST_DEVICE).build();
        interstitial.loadAd(adRequest);
    }
    Intent intent = new Intent(this, PlayFileService.class);
    startService(intent);
    bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.SecUpwN.AIMSICD.AIMSICD.java

private void startService() {
    // don't start service if disclaimer is not accepted
    if (!prefs.getBoolean(mDisclaimerAccepted, false))
        return;/*w  ww. ja va 2 s . c  o  m*/

    if (!mBound) {
        // Bind to LocalService
        Intent intent = new Intent(AIMSICD.this, AimsicdService.class);
        //Start Service before binding to keep it resident when activity is destroyed
        startService(intent);
        bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

        //Display the Device Fragment as the Default View
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.content_frame, new DetailsContainerFragment()).commit();
    }
}

From source file:net.sf.aria2.MainActivity.java

public void start() {
    uiThreadHandler = new CloseableHandler();

    backLink = new SimpleResultReceiver<Boolean>(uiThreadHandler) {
        @Override//from ww  w .  j a  v a2 s .c  om
        protected void receiveResult(Boolean started) {
            pref.setChecked(started);

            setPrefEnabled(true);
        }
    };

    pref.setOnPreferenceClickListener(this::changeAriaServiceState);

    bindService(sericeMoniker, this, Context.BIND_AUTO_CREATE);
}

From source file:net.sf.aria2.MainActivity.java

@Override
public void onServiceDisconnected(ComponentName name) {
    if (serviceLink != null) {
        // if we managed to obtain binder once without fail, we may as well try again
        serviceLink = null;//from  ww  w  . j a va2s  . c  o m

        if (!bindService(sericeMoniker, this, Context.BIND_AUTO_CREATE))
            bailOutBecauseOfBindingFailure();
    } else
        bailOutBecauseOfBindingFailure();
}

From source file:com.keithandthegirl.ui.activity.EpisodesFragment.java

/**
 * Binds to the instance of MediaPlayerService. If no instance of
 * MediaPlayerService exists, it first starts a new instance of the service.
 *///from   w  w w.  ja va 2  s. c om
private void bindToService() {
    Log.v(TAG, "bindToService : enter");

    Intent intent = new Intent(getActivity(), MediaPlayerService.class);

    if (MediaPlayerServiceRunning()) {
        Log.i(TAG, "bindToService : MediaPlayerServices is running");

        // Bind to LocalService
        getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    }

    Log.v(TAG, "bindToService : exit");
}

From source file:it.angrydroids.epub3reader.MainActivity.java

private void BLEServiceInit() {
    Intent bindIntent = new Intent(this, UartService.class);
    bindService(bindIntent, mBLEServiceConnection, Context.BIND_AUTO_CREATE);

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

From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java

private void bindService() {
    Intent intent = null;/*from  w w w.j a va 2 s.  co  m*/
    try {
        intent = new Intent(getApplication().getApplicationContext(),
                Class.forName(LppService.class.getName()));
        intent.setPackage("com.neighbor.ex.tong");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    if (intent != null) {
        getApplicationContext().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
    }
}

From source file:it.angrydroids.epub3reader.MainActivity.java

private void EPDMainServiceInit() {
    Intent bindIntent = new Intent(this, EPDMainService.class);
    bindService(bindIntent, mEPDMainServiceConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.cloudzilla.fb.FacebookServiceProxy.java

/**
 * Bind to the FacebookService./*from w  w  w .  j a va  2  s.c o  m*/
 *
 * @return true on success.
 */
private boolean connect(FacebookServiceListener facebookServiceListener) {
    mFacebookServiceListener = facebookServiceListener;
    mConnection = new FacebookServiceConnection();
    //        FACEBOOK_SERVICE_INTENT.setPackage("com.cloudzilla.fb");
    if (mContext.bindService(FACEBOOK_SERVICE_INTENT, mConnection, Context.BIND_AUTO_CREATE)) {
        Log.i(TAG, "Binded to FacebookService");
        return true;
    } else {
        Log.e(TAG, "Failed to bind to FacebookService");
        return false;
    }
}