Skip to content

Instantly share code, notes, and snippets.

@pbrisbin
Created October 10, 2010 00:32
Show Gist options
  • Select an option

  • Save pbrisbin/618766 to your computer and use it in GitHub Desktop.

Select an option

Save pbrisbin/618766 to your computer and use it in GitHub Desktop.
// establish the connection
private void connectToService() {
try {
bindService(new Intent(this, StreamMusic.class), onService, BIND_AUTO_CREATE);
}
catch (Exception e) {
Log.e(APP, "error binding to service.", e);
}
}
// once connected, set up the interface object
private ServiceConnection onService = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder iBinder) {
streamMusic = ((StreamMusic.LocalBinder)iBinder).getService();
}
public void onServiceDisconnected(ComponentName className) {
streamMusic = null;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment