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:eu.fistar.sdcs.pa.MainActivity.java

public void startService(View v) {

    updateLog("Starting the Protocol Adapter");

    // Create the Intent to start the PA with
    Intent intent = new Intent()
            .setComponent(new ComponentName(PAAndroidConstants.PA_PACKAGE, PAAndroidConstants.PA_ACTION));

    // Start the Protocol Adapter
    bindService(intent, serv, Context.BIND_AUTO_CREATE);
}

From source file:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java

@Override
public void onStart() {
    super.onStart();
    Intent intent = new Intent(getActivity(), TokenService.class);
    getActivity().bindService(intent, tokenServiceConnection, Context.BIND_AUTO_CREATE);
    cardInsertedReceiver = new CardPresentReciever();
    cardRemovedReceiver = new CardAbsentReciever();
    mobileIdBroadcastReceiver = new MobileIdBroadcastReceiver();
    connectivityBroadcastReceiver = new ConnectivityBroadcastReceiver();
    Timber.tag(TAG);//from  w  ww  .  j a  va 2s . com
}

From source file:be.deadba.ampd.SettingsActivity.java

private void bindService() {
    Log.d(TAG, "bindService");
    mBound = bindService(new Intent(this, MPDService.class), this, Context.BIND_AUTO_CREATE);
}

From source file:cm.aptoide.pt.ApkInfo.java

@Override
protected void onCreate(Bundle arg0) {
    AptoideThemePicker.setAptoideTheme(this);
    super.onCreate(arg0);
    setContentView(R.layout.app_info);//ww w. j av a 2  s  .c  o m

    //      getSupportActionBar().setIcon(R.drawable.brand_padding);
    //      getSupportActionBar().setTitle("");
    //      getSupportActionBar().setHomeButtonEnabled(true);
    //      getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (!isRunning) {
        isRunning = true;

        if (!serviceManagerIsBound) {
            bindService(new Intent(this, ServiceDownloadManager.class), serviceManagerConnection,
                    Context.BIND_AUTO_CREATE);
        } else {
            continueLoading();
        }

    }

}

From source file:com.anand.music.PlaylistFragment.java

/**
 * Launches the {@link com.jarekandshawnmusic.m.MediaPlayerService}
 * to play the requested playlist, or re-initializes an existing
 * {@link com.jarekandshawnmusic.m.MediaPlayerService} with a new playlist.
 * @param playlist the list of songs to play
 *///www .  j  a  v  a 2s  . c o m
public void setPlaylist(ArrayList<Integer> playlist) {
    if (mBound) {
        mMediaPlayerService.setPlaylist(playlist);
        mMediaPlayerService.play();
    } else {
        Activity containerActivity = getActivity();
        Intent playlistIntent = new Intent(containerActivity, MediaPlayerService.class);
        playlistIntent.putIntegerArrayListExtra("playlist", playlist);
        containerActivity.startService(playlistIntent);
        // We start this service and then bind to it, so we can control the playback
        // and get progress updates.
        containerActivity.bindService(playlistIntent, mConnection, Context.BIND_AUTO_CREATE);
    }
}

From source file:com.pandoroid.PandoroidPlayer.java

void doBindService() {

    // This is the master service start
    startService(new Intent(this, PandoraRadioService.class));

    // 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).
    bindService(new Intent(this, PandoraRadioService.class), m_connection, Context.BIND_AUTO_CREATE);

}

From source file:at.ac.tuwien.detlef.fragments.PlayerFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Singletons.i().getPlaylistDAO().addPlaylistChangedListener(this);
    Singletons.i().getEpisodeDAO().addEpisodeChangedListener(this);

    if (!MediaPlayerService.isRunning()) {
        Intent serviceIntent = new Intent(Detlef.getAppContext(), MediaPlayerService.class);
        Detlef.getAppContext().startService(serviceIntent);
    }//www. j  av a  2  s  .  c o  m
    Intent intent = new Intent(getActivity(), MediaPlayerService.class);
    getActivity().bindService(intent, connection, Context.BIND_AUTO_CREATE);
}

From source file:com.ronak.musicbox.fragment.AdapterStationsList.java

private void bindWithServiceAndExecute(final Station station) {
    Intent intent = new Intent(context, MyService.class);
    context.bindService(intent, new ServiceConnection() {
        public static final String TAG = "AdapterStationsList BS";

        @Override/*from  w  ww  .  j  av a  2 s.  c o m*/
        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            MyService.ServiceBinder servicBinder = (MyService.ServiceBinder) iBinder;
            MyService myServiceEngine = servicBinder.getService();
            try {
                myServiceEngine.prepare(station);
            } catch (Exception ex) {
                Log.e(TAG, "while preparing for " + getClass().getName());
            }
        }

        @Override
        public void onServiceDisconnected(ComponentName componentName) {
            Log.e(TAG, "service");
        }
    }, Context.BIND_AUTO_CREATE);

}

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

@Override
public void onStart() {
    super.onStart();
    // Bind to Service
    Intent intent = new Intent(getActivity(), DataService.class);
    getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.github.chenxiaolong.dualbootpatcher.settings.RomSettingsFragment.java

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

    // Start and bind to the service
    Intent intent = new Intent(getActivity(), SwitcherService.class);
    getActivity().bindService(intent, this, Context.BIND_AUTO_CREATE);
    getActivity().startService(intent);//w  w  w. jav a2  s  . c om
}