Guest User

Untitled

a guest
Jun 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // establish the connection
  2. private void connectToService() {
  3. try {
  4. bindService(new Intent(this, StreamMusic.class), onService, BIND_AUTO_CREATE);
  5. }
  6. catch (Exception e) {
  7. Log.e(APP, "error binding to service.", e);
  8. }
  9. }
  10.  
  11. // once connected, set up the interface object
  12. private ServiceConnection onService = new ServiceConnection() {
  13. public void onServiceConnected(ComponentName className, IBinder iBinder) {
  14. streamMusic = ((StreamMusic.LocalBinder)iBinder).getService();
  15. }
  16.  
  17. public void onServiceDisconnected(ComponentName className) {
  18. streamMusic = null;
  19. }
  20. };
Add Comment
Please, Sign In to add comment