title: How pass data between activities using RxJava in android?
body: <p>I need to pass some data between two activities <code>MainActivity</code> and <code>ChildActivity</code>. Button click on <code>MainActivity</code> should open <code>ChildActivity</code> and send event with data. I have singleton: </p>
  
  <pre><code>Subject&lt;Object, Object&gt; subject = new SerializedSubject&lt;&gt;(PublishSubject.create());
  </code></pre>
  
  <p>and in <code>MainActivity</code> I have the following button click handler: </p>
  
  <pre><code>    public void onClick(){
          startActivity(new Intent(MainActivity.this, ChildActivity.class));
          subject.onNext(new SomeEvent(data));
      }
  </code></pre>
  
  <p>and event listener subscription in <code>ChildActivity</code> :</p>
  
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          addEventListeners();
      }
  
      private void addEventListeners() {
          subject.ofType(SomeEvent.class)
                  .observeOn(AndroidSchedulers.mainThread())
                  .subscribeOn(Schedulers.io()).subscribe(
                  event -&gt; {
                      loadData(event.getData());
                  });
      }
  </code></pre>
  
  <p>When I send event after starting activity and call <code>addEventListeners</code> in <code>ChildActivity</code> <code>onCreate</code> is still not subscribed to this event and <code>loadData()</code> is not called. </p>
  
  <p>What is proper way to pass data between activities using RxJava (if it's possible)?</p>