title: Why do I get "unable to start service Intent ... not found" when calling a service from a broadcastReceiver?
body: <p>I have a service in my app that is used to send http post requests to the server, called <code>Communicator</code>. I usually bind to it from my activities but now I need to call it from a broadcast receiver (because I need to send a request to the server once a minute) so I use <code>startService(intent)</code></p>
  
  <p>After some debugging, it seems that when the <code>startService(intent)</code> is called I'm getting the following error:</p>
  
  <pre><code>08-04 06:07:10.447: W/ActivityManager(1138): Unable to start service Intent { act=ping_states flg=0x14 cmp=com.example.imhere/.Pinger (has extras) } U=0: not found
  </code></pre>
  
  <p>This is my class that extends the <code>BroadcastReceiver</code>:</p>
  
  <pre><code>public class Pinger extends BroadcastReceiver{
  
  @Override
  public void onReceive(Context context, Intent intent) {
      //start the communicator and request to iterate over locations with true 'here state'
      Log.d("tom.debug", "Pinger class is calling to start the service"); //acording to the log, this part of the code is reached
      /*EDIT - THE ISSUE WAS FOUND HERE - See Imtiyaz's answer*/
      context.startService(intent); //so this is probably the reason I'm seeing the error
  
      }
  }
  </code></pre>
  
  <p>and here is the way I create the intent (according to the question here: <a href="https://stackoverflow.com/questions/11434056/how-to-run-a-method-every-x-seconds">How to run a method every X seconds</a> ):</p>
  
  <pre><code>private void startPinging() {
      Date when = new Date(System.currentTimeMillis() + (MINUTE));
      try{
             Intent pingerIntent = new Intent(this.getApplicationContext(), Pinger.class);
             pingerIntent.setAction(getString(R.string.intent_action_ping_states));
  
             PendingIntent pendingIntent = PendingIntent.getBroadcast(
                  this.getApplicationContext(), 
                  0,
                  pingerIntent,
                  PendingIntent.FLAG_CANCEL_CURRENT);
  
             AlarmManager alarms = (AlarmManager) this.getApplicationContext().getSystemService(
                  Context.ALARM_SERVICE);
  
             alarms.set(AlarmManager.RTC_WAKEUP,
                     when.getTime(),
                     pendingIntent);
  
             alarmSet = true;
  
             Log.d("tom.debug", "startPinging: alarmSet is now true");
  
          } catch(Exception e){
             e.printStackTrace();
          }
  }
  </code></pre>
  
  <p>I assume the manifest file is also relevant:</p>
  
  <pre><code>...
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
  
      &lt;receiver android:enabled="true"
          android:exported="false"
          android:name="com.example.imhere.Pinger" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="@string/intent_action_ping_states" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
      &lt;service
          android:name="com.example.imhere.Communicator"
          android:enabled="true"
          android:exported="true" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="@string/intent_action_ping_states" /&gt;
          &lt;/intent-filter&gt;
      &lt;/service&gt;
      ...
  &lt;/application&gt;
  ...
  </code></pre>