title: Null pointer exception while sending data from service to activity using intent
body: <p>I am sending data from Service Class to Main Activity using Bundle but its sending null. </p>
  
  <p><strong>Service Class</strong></p>
  
  <pre><code>Intent intent = new Intent(LocationService.this, MainActivity.class);
  Bundle b = new Bundle();
  b.putString("final_address", addressText);
  intent.putExtras(b);
  startActivity(intent);
  </code></pre>
  
  <p><strong>Main Activity</strong></p>
  
  <pre><code>Intent intentReceived = getIntent();
  Bundle b = intentReceived.getExtras();
  address = b.getString("final_address");
  </code></pre>
  
  <p>I also tried sending it through broadcasting messages but it failed too.See below:</p>
  
  <p><strong>Service Class</strong></p>
  
  <pre><code>public static final String ADDRESSIDENTIFY = "address_identify";
  public static final String ADDRESS_PATH = "address_path";
  
  Intent intent = new Intent(ADDRESSIDENTIFY);
  intent.putExtra(ADDRESS_PATH, addressText);
  sendBroadcast(intent);
  </code></pre>
  
  <p><strong>Main Activity</strong></p>
  
  <pre><code>private BroadcastReceiver receiver = new BroadcastReceiver() {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          Bundle bundle = intent.getExtras();
          if (bundle != null) {
              address = bundle.getString(LocationService.ADDRESS_PATH);
  
          }
      }
  };
  </code></pre>
  
  <p>and calling this in main activity on create</p>
  
  <pre>registerReceiver(receiver, new IntentFilter(LocationService.ADDRESSIDENTIFY));</pre>
  
  <p>I have declared service in manifest too.</p>
  
  <pre><code>&lt;service
    android:name="com.gampzz.bhojannearby.LocationService"
    android:enabled="true"&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p>What should i do..Where am I wrong??</p>