title: listen to intent in background
body: <p>I am new to android, I have created intent's like this -</p>
  
  <pre><code>&lt;receiver android:name=".IncommigCallListener" &gt;
        &lt;intent-filter&gt;
               &lt;action android:name="android.intent.action.PHONE_STATE" /&gt;
        &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  &lt;receiver android:name=".OutgoingCallReciever" &gt;
           &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.NEW_OUTGOING_CALL" /&gt;
           &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>Now i created a service like this -</p>
  
  <pre><code>&lt;service
         android:name=".CallLogger"
         android:exported="false"/&gt;
  </code></pre>
  
  <p>Class <code>CallLogger</code></p>
  
  <pre><code>public class CallLogger extends IntentService {
      public CallLogger(String name) {
          super(name);
          // TODO Auto-generated constructor stub
      }
  
      @Override
      protected void onHandleIntent(Intent arg0) {
          // TODO Auto-generated method stub
          System.out.println("service started");
      }
  }
  </code></pre>
  
  <p>I don't want to have any activity in my application, i just want to start the service so that it can work in background and receive <code>PHONE_STATE</code> and <code>NEW_OUTGOING_CALL</code> intent.</p>
  
  <p>When i start this application, it doesn't log anything on <code>PHONE_STATE</code> or <code>NEW_OUTGOING_CALL</code> intent.</p>
  
  <p>How can start service in background without using any activity ?</p>
  
  <p><strong>Edit :</strong></p>
  
  <pre><code>public class OutgoingCallReciever extends BroadcastReceiver {
      @Override
      public void onReceive(Context ctx, Intent intent) {
           String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class IncommigCallListener extends PhoneStateListener {
      @Override
      public void onCallStateChanged(int state, String incomingNumber) {
          switch (state) {
          case TelephonyManager.CALL_STATE_RINGING:
              String incommingCallNumber = incomingNumber;
              System.out.println("incomming call : " + incomingNumber);
              break;
          }
      }
  }
  </code></pre>