title: error : BroadcastReceiver trying to return result
body: <p>I am trying to understand when device is connected to internet. </p>
  
  <p>but I get this error : </p>
  
  <pre><code>03-12 20:35:06.801: E/BroadcastReceiver(28892): BroadcastReceiver trying to return result during a non-ordered broadcast
  </code></pre>
  
  <hr>
  
  <p>My BroadcastReceiver  :</p>
  
  <pre><code>public class ConnectivityChangeReceiver extends BroadcastReceiver {
  
  
  @Override
  public void onReceive(Context context, Intent intent) {
  
  
      // Explicitly specify that which service class will handle the intent.
      ComponentName comp = new ComponentName(context.getPackageName(),
              YourService.class.getName());
  
      intent.putExtra("isNetworkConnected",isConnected(context));
      context.startService((intent.setComponent(comp)));
  
  
      setResultCode(Activity.RESULT_OK);
  }
  
  public  boolean isConnected(Context context) {
         ConnectivityManager connectivityManager = ((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE));
         NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
         return networkInfo != null &amp;&amp; networkInfo.isAvailable() &amp;&amp; networkInfo.isConnected();
   }
  
  }
  </code></pre>
  
  <hr>
  
  <p>My service :</p>
  
  <pre><code>public class YourService extends IntentService{
  
  public YourService() {
      super("Test");
      // TODO Auto-generated constructor stub
  }
  
  @Override
  protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    boolean isNetworkConnected = extras.getBoolean("isNetworkConnected");
    // your code
    if(isNetworkConnected){
        Log.e("TAG", "Yes");
    }
  
  }
  
  }
  </code></pre>
  
  <hr>
  
  <p>My manifest :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.ex80"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="11"
      android:targetSdkVersion="18" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name="com.example.ex80.MainActivity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;receiver android:name=".ConnectivityChangeReceiver" &gt;
  &lt;intent-filter&gt;
      &lt;action android:name="android.net.conn.CONNECTIVITY_CHANGE" /&gt;
  &lt;/intent-filter&gt;
  &lt;/receiver&gt;        
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>