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:ca.farrelltonsolar.classic.MonitorApplication.java

public void onCreate() {
    super.onCreate();

    MonitorApplication.context = getApplicationContext();
    if (Constants.DEVELOPER_MODE) {
        StrictMode.enableDefaults();/*  www .ja  v a  2  s .c o  m*/
    }
    InitializeChargeStateLookup();
    InitializeChargeStateTitleLookup();
    InitializeMessageLookup();
    try {
        configuration = ComplexPreferences.getComplexPreferences(this, null, Context.MODE_PRIVATE);
        chargeControllers = configuration.getObject("devices", ChargeControllers.class);
    } catch (Exception ex) {
        Log.w(getClass().getName(), "getComplexPreferences failed to load");
        chargeControllers = null;
    }
    if (chargeControllers == null) { // save empty collection
        chargeControllers = new ChargeControllers(context);
    }
    if (chargeControllers.uploadToPVOutput()) {
        startService(new Intent(this, PVOutputService.class)); // start PVOutputService intent service
    }
    this.registerActivityLifecycleCallbacks(this);
    bindService(new Intent(this, UDPListener.class), UDPListenerServiceConnection, Context.BIND_AUTO_CREATE);
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    if (wifi != null) {
        wifiLock = wifi.createWifiLock("ClassicMonitor");
    }
    Log.d(getClass().getName(), "onCreate complete");
}

From source file:ca.etsmtl.applets.etsmobile.NewsListActivity.java

private void connectToFetcherService() {
    final Intent i = new Intent(this, NewsService.class);
    if (!serviceIsRunning()) {
        startService(i);/*from   w w w.  j  av a2 s . c o m*/
        navBar.showLoading();
    }
    bindService(i, connection, Context.BIND_AUTO_CREATE);
}

From source file:com.idlegandalf.ledd.helper.LedDHelper.java

public LedDHelper(LedDDaemon ledDDaemon, Context appl) {
    this.context = appl;
    this.dRequests = new LinkedBlockingQueue<>();
    this.ledDDaemon = ledDDaemon;

    Intent intent = new Intent(appl, ColorService.class);
    appl.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:net.gcompris.GComprisActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    intent.setPackage("com.android.vending");
    bindService(intent, m_serviceConnection, Context.BIND_AUTO_CREATE);
}

From source file:edu.mit.media.funf.funfohmage.MainPipeline.java

@Override
public void onCreate() {
    super.onCreate();
    Log.setAppName("funfohmagetrial");
    //funfohmage/*from www.j  a va 2 s . c  o  m*/
    if (!Log.isConnected()) {
        Log.i("dony", "Connecting to Log");
        bindService(new Intent(ISystemLog.class.getName()), Log.SystemLogConnection, Context.BIND_AUTO_CREATE);
    }
    Log.i("dony", "Log Starting in service");
}

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

@Override
public void onStart() {
    super.onStart();
    Intent intent = new Intent(this, WalletService.class);
    bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);

    IntentFilter filter = new IntentFilter(Constants.WALLET_TRANSACTION_CONFIDENCE_CHANGED_ACTION);
    filter.addAction(Constants.WALLET_DOWNLOAD_DONE_ACTION);
    LocalBroadcastManager.getInstance(this).registerReceiver(walletBalanceChangeBroadcastReceiver, filter);
}

From source file:me.henrytao.bootstrapandroidlibrarydemo.activity.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDonateItems = getResources().getStringArray(R.array.donate_items);
    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    bindService(serviceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
}

From source file:mobile.client.iot.pzalejko.iothome.MainActivity.java

@Override
protected void onStart() {
    super.onStart();
    if (!new NetworkValidator(this).validate()) {
        return;//from www . jav a2 s  . c o  m
    }

    // start a MQTT service.
    final Intent intent = new Intent(this, MqttService.class);
    startService(intent);
    bindService(intent, connection, Context.BIND_AUTO_CREATE);
    broadcaster.registerReceiver((receiver), new IntentFilter(MqttEvent.EVENT_IN));
}

From source file:com.wojtechnology.sunami.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mSongPlayingChecked = false;//from  ww  w .  j ava2  s  .c  o m
    mSoundcloud = new Soundcloud(this);

    // Setup mToolbar at top of app
    mToolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.title_activity_main);
    getSupportActionBar().setElevation(25f);

    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mProgressBar.setVisibility(View.VISIBLE);
    mOuterLayout = (OuterLayout) findViewById(R.id.outer_layout);
    mHandler = new Handler();

    // Setup navigation drawer from left
    mDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_navigation_drawer);
    mDrawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout),
            mToolbar, this);

    mState = STATE_SONGS;
    mDrawerFragment.updateChoices(mState);

    mRecyclerView = (RecyclerView) findViewById(R.id.drawer_list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    Intent serviceIntent = new Intent(MainActivity.this, TheBrain.class);
    startService(serviceIntent);
    bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.appdevper.mediaplayer.activity.BaseActivity.java

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

    LogHelper.d(TAG, "Activity onCreate");

    if (Build.VERSION.SDK_INT >= 21) {
        // Since our app icon has the same color as colorPrimary, our entry in the Recent Apps
        // list gets weird. We need to change either the icon or the color
        // of the TaskDescription.
        ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getTitle().toString(),
                BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_white),
                ResourceHelper.getThemeColor(this, R.attr.colorPrimary, android.R.color.darker_gray));
        setTaskDescription(taskDesc);/*from   w w w  .  j  av  a  2 s. c om*/
    }
    //        mMediaBrowser = new MediaBrowserCompat(this,
    //                new ComponentName(this, MusicService.class), mConnectionCallback, null);
    Intent intent = new Intent(this, MusicService.class);
    bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
}