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.rks.musicx.base.BasePlayingFragment.java

@Override
public void onResume() {
    super.onResume();
    if (getActivity() == null) {
        return;//w  w w . j a  v  a 2  s  .c  om
    }
    if (!mServiceBound) {
        Intent intent = new Intent(getActivity(), MusicXService.class);
        getActivity().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
        getActivity().startService(intent);
        IntentFilter filter = new IntentFilter();
        filter.addAction(META_CHANGED);
        filter.addAction(PLAYSTATE_CHANGED);
        filter.addAction(POSITION_CHANGED);
        filter.addAction(ITEM_ADDED);
        filter.addAction(ORDER_CHANGED);
        try {
            getActivity().registerReceiver(broadcastReceiver, filter);
        } catch (Exception e) {
            // already registered
        }
    } else {
        if (musicXService != null) {
            reload();
        }
    }
    Glide.get(getContext()).clearMemory();
}

From source file:com.fox.myappstore.MainActivity.java

private void bindNetworkService() {
    Intent intent = new Intent(this, NetworkService.class);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:de.tudarmstadt.dvs.myhealthassistant.pubsubexample.withfragment.MFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);/* ww  w.  ja v  a2 s  . co m*/

    mList = new ArrayList<MEvent>();
    mAdapter = new MListAdapter(getActivity().getApplicationContext(), 0);
    setListAdapter(mAdapter);
    // setListShown(false);

    mList.add(new MEvent("Blood Pressure", SensorReadingEvent.BLOOD_PRESSURE));
    mList.add(new MEvent("Heart Rate", SensorReadingEvent.HEART_RATE));
    mList.add(new MEvent("Heart Rate Variability", SensorReadingEvent.HR_VARIABILITY));
    // mList.add(new MEvent("Accelerometer",
    // SensorReadingEvent.ACCELEROMETER));
    mList.add(new MEvent("Accelerometer in m/s2", SensorReadingEvent.ACCELEROMETER_ON_DEVICE));
    mList.add(new MEvent("Accelerometer in G", SensorReadingEvent.ACCELEROMETER_IN_G));
    mList.add(new MEvent("Activity Recognition", SensorReadingEvent.ACTIVITY_REHA));
    // mList.add(new MEvent("Scale", "?"));
    // mList.add(new MEvent("ECG To Heart Rate",
    // SensorReadingEvent.ECG_STREAM));
    mList.add(new MEvent("BodyTemp in Celsius", SensorReadingEvent.BODY_TEMPERATURE_IN_CELSIUS));
    mList.add(new MEvent("BodyTemp in Fahrenheit", SensorReadingEvent.BODY_TEMPERATURE_IN_FAHRENHEIT));
    mList.add(new MEvent("HR + Fidelity", SensorReadingEvent.HR_FIDELITY));
    mList.add(new MEvent("Weight in Kg", SensorReadingEvent.WEIGHT_IN_KG));
    mList.add(new MEvent("Weight in Lbs", SensorReadingEvent.WEIGHT_IN_LBS));
    mList.add(new MEvent("Hr With Alarm", NotificationEvent.EVENT_TYPE));

    mAdapter.setData(mList);

    /* Preferences */
    // preferences = PreferenceManager.getDefaultSharedPreferences(this
    // .getActivity());

    registerForContextMenu(getListView());
    setHasOptionsMenu(true);

    /** Connection to myHealthHub Service */
    myHealthHubIntent = new Intent(IMyHealthHubRemoteService.class.getName());
    getActivity().bindService(myHealthHubIntent, myHealthAssistantRemoteConnection, Context.BIND_AUTO_CREATE);

    // initialize event counter
    eventCounter = 0;
    // register management receiver for receiving start/stop events and
    // sensor connectivity information
    getActivity().registerReceiver(myManagementReceiver, new IntentFilter(AbstractChannel.MANAGEMENT));

    /*
     * register reading receiver for the desired event types. You can also
     * register individual receivers for specific event types by having
     * multiple "myReadingReceivers".
     */
    IntentFilter inFil = new IntentFilter();
    inFil.addAction(SensorReadingEvent.BLOOD_PRESSURE);
    inFil.addAction(SensorReadingEvent.HEART_RATE);
    inFil.addAction(SensorReadingEvent.WEIGHT_IN_KG);
    inFil.addAction(SensorReadingEvent.WEIGHT_IN_LBS);
    inFil.addAction(SensorReadingEvent.BODY_TEMPERATURE_IN_CELSIUS);
    inFil.addAction(SensorReadingEvent.BODY_TEMPERATURE_IN_FAHRENHEIT);
    inFil.addAction(SensorReadingEvent.HR_FIDELITY);
    inFil.addAction(SensorReadingEvent.HR_VARIABILITY);
    inFil.addAction(SensorReadingEvent.ACCELEROMETER);
    inFil.addAction(SensorReadingEvent.ACCELEROMETER_ON_DEVICE);
    inFil.addAction(SensorReadingEvent.ACCELEROMETER_IN_G);
    inFil.addAction(NotificationEvent.EVENT_TYPE);
    // inFil.addAction(ActivityEventReha.EVENT_TYPE);
    inFil.addAction(SensorReadingEvent.ACTIVITY_REHA);

    getActivity().registerReceiver(myReadingReceiver, inFil);

}

From source file:marto.rtl_tcp_andro.DeviceOpenActivity.java

/** 
 * Starts the tcp binary/*w ww.  j  av  a  2s  .  c om*/
 */
public void startBinary(final String arguments, final int fd, final String uspfs_path) {
    try {
        //start the service
        this.args = arguments;
        this.fd = fd;
        this.uspfs_path = uspfs_path;
        final Intent intent = new Intent(this, BinaryRunnerService.class);
        startService(intent);
        bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

    } catch (Exception e) {
        finishWithError(e);
    }
}

From source file:com.coinblesk.client.MainActivity.java

private void startWalletService(boolean bindService) {
    Intent walletServiceIntent = new Intent(this, WalletService.class);
    startService(walletServiceIntent);/*from w  w w. j av a  2s  .c om*/
    if (bindService) {
        bindService(walletServiceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
    }
}

From source file:fr.forexperts.ui.ArticleListFragment.java

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

    String RSS_LINK = "http://feeds.bbci.co.uk/news/business/economy/rss.xml";
    LoadingNewsTask task = new LoadingNewsTask();
    task.execute(RSS_LINK);//from ww w.j ava  2 s  .  com

    // Bind to Service
    Intent intent = new Intent(getActivity(), DataService.class);
    getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:at.alladin.rmbt.android.loopmode.LoopModeTestFragment.java

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

    if (infoCollector != null) {
        infoCollector.init();//from   ww w. jav  a  2s . co  m
    }

    getActivity().getActionBar().hide();
    ((RMBTMainActivity) getActivity()).setLockNavigationDrawer(true);

    // Bind to RMBTLoopService
    final Intent loopServiceIntent = new Intent(getActivity(), RMBTLoopService.class);
    getActivity().bindService(loopServiceIntent, this, 0);

    final Intent rmbtServiceIntent = new Intent(getActivity(), RMBTService.class);
    getActivity().bindService(rmbtServiceIntent, rmbtServiceConnection, Context.BIND_AUTO_CREATE);

    final IntentFilter actionFilter = new IntentFilter(RMBTService.BROADCAST_TEST_FINISHED);
    getActivity().registerReceiver(receiver, actionFilter);

    Log.d(TAG, "BIND LOOP MODE SERVICES");

    handler.post(updateTask);

    //getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

From source file:butter.droid.base.torrent.TorrentService.java

public static void bindHere(Context context, ServiceConnection serviceConnection) {
    Intent torrentServiceIntent = new Intent(context, TorrentService.class);
    context.bindService(torrentServiceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.peptrack.gps.locationupdatesforegroundservice.MainActivity.java

@Override
protected void onStart() {
    super.onStart();
    PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);

    mRequestLocationUpdatesButton = (Button) findViewById(R.id.request_location_updates_button);
    mRemoveLocationUpdatesButton = (Button) findViewById(R.id.remove_location_updates_button);

    mRequestLocationUpdatesButton.setOnClickListener(new View.OnClickListener() {
        @Override//from   w  w w  .j  a  v a2 s  . com
        public void onClick(View view) {
            if (checkLocationPermissions() && checkInternetPermissions()) {
                startLocationUpdates();
                //mService.requestLocationUpdates();
            } else {
                //required permission not granted
            }
        }
    });

    mRemoveLocationUpdatesButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mService.removeLocationUpdates();
        }
    });

    // Restore the state of the buttons when the activity (re)launches.
    setButtonsState(Utils.requestingLocationUpdates(this));

    // Bind to the service. If the service is in foreground mode, this signals to the service
    // that since this activity is in the foreground, the service can exit foreground mode.
    bindService(new Intent(this, LocationUpdatesService.class), mServiceConnection, Context.BIND_AUTO_CREATE);
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

@Override
public void onStart() {
    super.onStart();
    if (!utils.signInFlowStarted) {
        mTaskFragment.connectPlayServices(findViewById(VIEW_ID_POPUPS));
    }/*from ww w  .jav  a 2  s .com*/

    if (!IAPBound) {
        Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        intent.setPackage("com.android.vending");
        if (mAppContext != null) {
            IAPBound = mAppContext.bindService(intent, IAPConnection, Context.BIND_AUTO_CREATE);
        }
    }
}