title: BroadcastReceiver in Service not working
body: <p>This is my service file:</p>
  
  <pre><code>public class SMSCounterService extends Service {
      /** Called when the activity is first created. */
      @Override
      public void onCreate() {
          Log.d(LOG_TAG, "SMSCounterService: Constructor");
          super.onCreate();
          dbActivities = new DBActivities(this);
          dbActivities.open();    // Create or open the existing DB if already created
  
          IntentFilter filter = new IntentFilter();
          filter.addAction("android.provider.Telephony.SMS_SENT");
          registerReceiver(receiver, filter);
      }
  
      @Override
      public void onDestroy() {
          unregisterReceiver(receiver);
          dbActivities.close();
          super.onDestroy();
      }
  
      private final BroadcastReceiver receiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              if(intent.getAction().equals("android.provider.Telephony.SMS_SENT")) {
                  smsCount++;
                  Log.d(LOG_TAG, "SMSCounterService: smsCount=" +smsCount);
                  long dbInsertReturn = dbActivities.insertIntoDB(smsCount);
              }
          }
      };
  </code></pre>
  
  <p>I can see the log "SMSCounterService: Constructor". So the onCreate() method is called. But when I send an SMS, the BroadcastReceiver is not able to identify it.</p>