public void onActivityResume(Activity activity) {
   super.onActivityResume(activity);
   ConnectionFactory.getNowPlayingPoller(activity.getApplicationContext())
       .subscribe(mNowPlayingHandler);
   if (mEventClient != null) {
     mEventClient.setController(this);
   }
   if (mMusicManager != null) {
     mMusicManager.setController(this);
   }
   if (mControlManager != null) {
     mControlManager.setController(this);
   }
 }
 public void onActivityPause() {
   ConnectionFactory.getNowPlayingPoller(mActivity.getApplicationContext())
       .unSubscribe(mNowPlayingHandler);
   if (mMusicManager != null) {
     mMusicManager.setController(null);
     mMusicManager.postActivity();
   }
   if (mControlManager != null) {
     mControlManager.setController(null);
   }
   if (mEventClient != null) {
     mEventClient.setController(null);
   }
   super.onActivityPause();
 }
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   IEventClientManager client = ManagerFactory.getEventClientManager(mMovieDetailsController);
   switch (keyCode) {
     case KeyEvent.KEYCODE_VOLUME_UP:
       client.sendButton(
           "R1", ButtonCodes.REMOTE_VOLUME_PLUS, false, true, true, (short) 0, (byte) 0);
       return true;
     case KeyEvent.KEYCODE_VOLUME_DOWN:
       client.sendButton(
           "R1", ButtonCodes.REMOTE_VOLUME_MINUS, false, true, true, (short) 0, (byte) 0);
       return true;
   }
   client.setController(null);
   boolean handled = (mKeyTracker != null) ? mKeyTracker.doKeyDown(keyCode, event) : false;
   return handled || super.onKeyDown(keyCode, event);
 }