title: How to run a service when only wifi connection is active on android?
body: <p>How can I do that? I want service is run,when only wifi is active,when change is not.<br><br>
  When the app opens firstly,for there is not changed wifi connection,so app doesn't work.<br>
  I hope I could tell.<br>
  <br>
  onReceive(..) in BroadcastReceiver class</p>
  
  <pre><code>        public void onReceive(Context context, Intent intent) {
          // TODO Auto-generated method stub
  
          ConnectivityManager conMan = (ConnectivityManager) context
                  .getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo netInfo = conMan.getActiveNetworkInfo();
  
          if (netInfo.isConnected()) {
  
              Intent ServiceIntent = new Intent(context, BackService.class);
              context.startService(ServiceIntent);
  
          } else {
              Intent ServiceIntent = new Intent(context, BackService.class);
              context.stopService(ServiceIntent);
          }
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>        &lt;receiver android:name=".MyStartServiceReceiver" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
              &lt;action android:name="android.net.conn.CONNECTIVITY_CHANGE"/&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>WiFi connection is changed to start more than one service can be.So it's a problem.How can I When wifi connection is active not a changed,background service is running?</p>