title: send intent from service to activity
body: <p>I'm trying to return the result from an <code>IntentSerivce</code> to the <code>mainactivity</code> using an intent, but I can't get it to work.
  The <code>IntentService</code> receives the intent from the activity without a problem, does it's thing and gets a <code>JSONstring</code>. Now the only problem left is to send this String back to the activity.</p>
  
  <p>Here is the method in the mainactivity:</p>
  
  <pre><code>public String RTConn(String query){
      System.out.println("Querying Rotten Tomatoes.");
      Intent rtIntent = new Intent(MainActivity.this, RTConnection.class);
      rtIntent.putExtra("query", query);
      bindService(rtIntent, RTConnection, Context.BIND_AUTO_CREATE);
      startService(rtIntent);
      String json = getIntent().getStringExtra("json");
      return json;
  </code></pre>
  
  <p>And here is the IntentService:</p>
  
  <pre><code>public void onStart(Intent intent, int startId){
      System.out.println("intent Received");
      String jsonString = rottenTomatoesSearch(intent.getStringExtra("query"));
      Intent RTRetur = new Intent(RTConnection.this, MainActivity.class);
      RTRetur.putExtra("json", jsonString);
      startActivity(RTRetur);
  }
  </code></pre>
  
  <p>Obviously the startActivity isn't working, but what else is there to use? (I would rather not use a broadcast receiver).
  Regards Peter L.</p>
  
  <p>Update</p>
  
  <p>this it how the MainActivity looks atm:</p>
  
  <pre><code>public static final String RECEIVE_JSON = "student.kau.RECEIVE_JSON";
  private BroadcastReceiver RTReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
          System.out.println("broadcast Received: "+intent.getAction());
          if(intent.getAction().equals(RECEIVE_JSON)){
              System.out.println("JSON Received.");
              String serviceJsonString = intent.getStringExtra("json");
          }
      }
  };
  </code></pre>
  
  <p>This code is the onCreate: </p>
  
  <pre><code>LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this);
      IntentFilter intentFilter = new IntentFilter();
      intentFilter.addAction(RECEIVE_JSON);
      bManager.registerReceiver(RTReceiver, intentFilter);
  </code></pre>
  
  <p>This is the method:</p>
  
  <pre><code>public void onStart(Intent intent, int startId){
      System.out.println("intent Received");
      String query = intent.getStringExtra("query");
      String jsonString = rottenTomatoesSearch(query);
      System.out.println("Fetching done");
      Intent RTRetur = new Intent(MainActivity.RECEIVE_JSON);
      System.out.println("action: "+RTRetur.getAction());
      RTRetur.putExtra("json", jsonString);
      sendBroadcast(RTRetur);
  
  }
  </code></pre>
  
  <p>The last trace in logcat is the <code>System.out.println("action: "+RTRetur.getAction()");</code></p>
  
  <pre><code>-action: 
  
      student.kau.RECEIVE_JSON
  </code></pre>