title: Android: calling a method from a Service to an Activity
body: <p>I have a simple question to solve, but I am not sure how to do it.</p>
  
  <p>I have a class that extends Service that runs a thread looking for a TCP connection. If one comes in, it read an input message.</p>
  
  <p>If the input message is "START", I start an activity, in this fashion:</p>
  
  <pre><code>Intent dialogIntent = new Intent(getBaseContext(), VoIPCall.class);
  dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  dialogIntent.putExtra("inetAddress", clientSocket.getInetAddress());
  getApplication().startActivity(dialogIntent);
  </code></pre>
  
  <p>While this activity is running, the Service keeps running. At some point I may reserve a "STOP". I would like to call a method in the previously created Activity but I am not sure how to interact with it.</p>
  
  <p>I do not want to use a static method. How can I please do that?</p>
  
  <p>Thank you very much,</p>
  
  <p>EDIT: I changed my code to this:</p>
  
  <pre><code>Intent dialogIntent = new Intent("com.voip.rudy.START_CALL");
  dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  dialogIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  dialogIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
  dialogIntent.putExtra("inetAddress", clientSocket.getInetAddress());
  getApplication().startActivity(dialogIntent);
  </code></pre>
  
  <p>And in the manifest:</p>
  
  <pre><code>&lt;activity android:name=".VoIPCall"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="com.voip.rudy.START_CALL" /&gt;
          &lt;action android:name="com.voip.rudy.STOP_CALL" /&gt;
          &lt;category android:name="android.intent.category.DEFAULT" /&gt;
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  
  
  &lt;category android:name="android.intent.category.DEFAULT" /&gt; was required to avoid having it crash.
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>The solution given has fixed my issue but I wanted to actually act on member variables on that class, that are previously initialized. Say I call the constructor, then I would like to go back into this activity and act on the member variables.</p>
  
  <p>The member variables are not initialized when I call one action after another, it seems to create a new activity somehow. Would there be anyway to act on the same activity, and keep the objects intact please?</p>
  
  <p>James</p>