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.sdingba.su.lanya.MainActivity.java

/**
 *  ?/*w w  w . j a  va 2 s . c o m*/
 */
private void service_init() {
    //?
    Intent bindIntent = new Intent(this, UartService.class);
    bindService(bindIntent, mServiceConnection, Context.BIND_AUTO_CREATE);

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

From source file:gdg.androidtitlan.spotifymvp.example.ui.fragment.AudioPlayerFragment.java

@Override
public void onStartAudioService(String trackUrl, ServiceConnection serviceConnection) {

    Intent serviceIntent = new Intent(getActivity(), AudioPlayerService.class);
    serviceIntent.putExtra(AudioPlayerService.EXTRA_TRACK_PREVIEW_URL, trackUrl);

    if (Utils.isAudioPlayerServiceRunning(AudioPlayerService.class, getActivity()) && !isPlayerPlaying) {
        trackCurrentPosition = 0;// w w  w. ja  v a2  s .  co m
        getActivity().getApplicationContext().stopService(serviceIntent);
        getActivity().getApplicationContext().startService(serviceIntent);
    } else if (!Utils.isAudioPlayerServiceRunning(AudioPlayerService.class, getActivity())) {
        trackCurrentPosition = 0;
        getActivity().getApplicationContext().startService(serviceIntent);
    }
    if (audioPlayerService == null) {
        getActivity().getApplicationContext().bindService(serviceIntent, serviceConnection,
                Context.BIND_AUTO_CREATE);
    }
}

From source file:com.mk4droid.IMC_Activities.Fragment_Map.java

/**
 *            OnCreateView /*w w w . j ava  2 s.c om*/
 * 
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // ----- Inflate the view ---------
    if (vframelayout_main != null) {
        ViewGroup parent = (ViewGroup) vframelayout_main.getParent();
        parent.removeView(vframelayout_main);
    } else {
        vframelayout_main = inflater.inflate(R.layout.framelayout_map, container, false);
    }

    ctx = vframelayout_main.getContext();

    //------- Add fragment_map ----
    if (fmap_main == null) {
        fmap_main = SupportMapFragment.newInstance();
        FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.flmain, fmap_main);
        fragmentTransaction.commit();
    }

    getFragmentManager().addOnBackStackChangedListener(new OnBackStackChangedListener() {
        public void onBackStackChanged() {
            if (fmap_main == null && !Fragment_Issue_Details.isVisible && FActivity_TabHost.IndexGroup == 0) {
                onResume();
            }
        }
    });

    //-----------------------------
    pbgeneral = (ProgressBar) vframelayout_main.findViewById(R.id.pbgeneral);
    pbgeneral.bringToFront();

    //---- Bind Location Service --------------
    IntLocServ = new Intent(ctx, Service_Location.class);

    if (!isLocServBound && FActivity_TabHost.IndexGroup == 0)
        ctx.bindService(IntLocServ, mLocConnection, Context.BIND_AUTO_CREATE);

    FActivity_TabHost.IndexGroup = 0;

    //-----Start Data Service ------------
    IntDataServ = new Intent(ctx, Service_Data.class);
    ctx.startService(IntDataServ);

    return vframelayout_main;
}

From source file:com.github.jberkel.pay.me.IabHelper.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 va2  s . c o  m
public void startSetup(final OnIabSetupFinishedListener listener) {
    checkNotDisposedAndThrow();

    if (mSetupDone)
        throw new IllegalStateException("IAB helper is already set up.");
    logDebug("Starting in-app billing setup.");

    if (!mContext.getPackageManager().queryIntentServices(BIND_BILLING_SERVICE, 0).isEmpty()) {
        // service available to handle that Intent
        mServiceConn = new BillingServiceConnection(listener);
        if (!mContext.bindService(BIND_BILLING_SERVICE, mServiceConn, Context.BIND_AUTO_CREATE)) {
            logWarn("Could not bind to service");
        }
    } else {
        // no service available to handle that Intent
        mSetupDone = true;
        if (listener != null) {
            listener.onIabSetupFinished(new IabResult(BILLING_UNAVAILABLE));
        }
    }
}

From source file:com.lithiumli.fiction.FictionActivity.java

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

    Log.d("fiction", "resuming");

    // Playback stuff
    Intent intent = new Intent(this, PlaybackService.class);
    startService(intent);/*from   w  ww. j  a  v a 2  s . c o m*/
    Log.d("fiction", "binding");
    intent = new Intent(this, PlaybackService.class);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

    IntentFilter filter = new IntentFilter();
    filter.addAction(PlaybackService.EVENT_PLAYING);
    filter.addAction(PlaybackService.EVENT_PLAY_STATE);
    LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, filter);
}

From source file:com.zentri.zentri_ble_command_demo.DeviceInfoActivity.java

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

    mLocalBroadcastManager.registerReceiver(mBroadcastReceiver, mReceiverIntentFilter);

    Intent serviceIntent = new Intent(getApplicationContext(), ZentriOSBLEService.class);
    bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.google.appinventor.components.runtime.ProbeBase.java

void doBindService() {
    // Establish a connection with the service. We use an explicit
    // class name because we want a specific service implementation that
    // we know will be running in our own process (and thus won't be
    // supporting component replacement by other applications).
    mainUIThreadActivity.bindService(new Intent(mainUIThreadActivity, FunfManager.class), mConnection,
            Context.BIND_AUTO_CREATE);
    mIsBound = true;/*w  w w . j  a v  a2  s  . c  o  m*/
    Log.i(TAG, "FunfManager is bound, and now we could have register dataRequests");

}

From source file:com.scooter1556.sms.androidtv.fragment.MainFragment.java

@Override
public void onStart() {
    if (audioPlayerIntent == null) {
        audioPlayerIntent = new Intent(getActivity(), AudioPlayerService.class);
        getActivity().bindService(audioPlayerIntent, audioPlayerConnection, Context.BIND_AUTO_CREATE);
        getActivity().startService(audioPlayerIntent);
    }// w  w w  . j  ava 2 s .c om

    super.onStart();
}

From source file:com.mbientlab.metawear.tutorial.starter.DeviceSetupActivityFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Activity owner = getActivity();/*from  w  ww  . j  a  va  2  s. c  om*/
    if (!(owner instanceof FragmentSettings)) {
        throw new ClassCastException("Owning activity must implement the FragmentSettings interface");
    }

    settings = (FragmentSettings) owner;
    owner.getApplicationContext().bindService(new Intent(owner, BtleService.class), this,
            Context.BIND_AUTO_CREATE);
    ctx = owner.getApplicationContext();
}

From source file:com.scooter1556.sms.androidtv.fragment.AudioPlayerFragment.java

@Override
public void onStart() {
    if (audioPlayerIntent == null) {
        audioPlayerIntent = new Intent(getActivity(), AudioPlayerService.class);
        getActivity().bindService(audioPlayerIntent, audioPlayerConnection, Context.BIND_AUTO_CREATE);
    }// w  w w .  j  a va2s. com

    super.onStart();
}