title: activity to activity callback listener
body: <p>Let's suppose 2 activities <code>Activity1</code> and <code>Activity2</code>. I need to call method <code>methodAct1()</code> (inside <code>Activity1</code>) from <code>methodAct2</code> (inside <code>Activity2</code>). I think it should work using callback listener - I don't want to use <code>EventBus</code> libs!</p>
  
  <p>I get <code>java.lang.NullPointerException</code> using this code:</p>
  
  <p>interface:</p>
  
  <pre><code>public interface MyListener {
      public void listen();
  }
  </code></pre>
  
  <p>Activity where event is created: </p>
  
  <pre><code>public class Activity2 extends Activity {
  
      private MyListener  myListener;
  
      public void setUpListener(MyListener myListener) {
          this.myListener = myListener;
      }
  
      private void doWork(){
          //do stuff 
          myListener.listen();
      }
  }
  </code></pre>
  
  <p>Activity where I'd like to get that event when work is done:</p>
  
  <pre><code>public class Activity1 extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          Activity2 activity2 = new Activity2();
          activity2.setUpListener(new setUpListener() {
              @Override
              public void listen() {
                  // get the event here
  
              }
          });
      }
  }
  </code></pre>