title: Send live data from Main Activity to Fragment
body: <p>I have this bluetooth headset which sends messages everytime to the main Activity. Within the main activity, I have a handler which will process these messages and output accordingly. </p>
  
  <p>I have a fragment which will make use of the messages. I cannot find a way to send live data from MainActivity to the fragment and I don't want to copy/paste the handler code to the fragment.</p>
  
  <p>Is there a way to send live data from the mainActivity to the fragment. I am including some code for you to better understand. </p>
  
  <p>MainActivity</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_dashboard);
          //Bluetooth headset which send live data
          tgDevice = new TGDevice(bluetoothAdapter, handler);
          tgDevice.connect(false);
      }
  
  
  /**
   * Handles messages from TGDevice
   * @param menu
   * @return
   */
  private final Handler handler = new Handler() {
      @Override
      public void handleMessage(Message msg) {
          switch (msg.what) {
              case TGDevice.MSG_STATE_CHANGE:
  
                  switch (msg.arg1) {
                      case TGDevice.STATE_IDLE:
                          break;
                      case TGDevice.STATE_CONNECTING:
                          //androidVersion.setText("Connecting...\n");
                          break;
                      case TGDevice.STATE_CONNECTED:
                          //androidVersion.setText("Connected" + "\t" +wifiInfo.getSSID());
                          tgDevice.start();
                          break;
                      case TGDevice.STATE_NOT_FOUND:
                          //tv.append("Can't find\n");
                          break;
                      case TGDevice.STATE_NOT_PAIRED:
                          //tv.append("not paired\n");
                          break;
                      case TGDevice.STATE_DISCONNECTED:
                          //tv.append("Disconnected\n");
                  }
  
                  break;
              case TGDevice.MSG_POOR_SIGNAL:
                  poorSignalValue = msg.arg1;
                  actionBar.setTitle("Signal: " + poorSignalValue);
                  Log.v("Poor", "Signal: " + poorSignalValue + "\n");
                  break;
              default:
                  break;
          }
      }
  };
  </code></pre>
  
  <p>The Fragment will make use of the poorsignal as well as other variables. What is the best way to do this? Other fragments will also make use of the TGDevice. </p>