title: Android Pending Intent to start service
body: <p>So I have a service, in the <code>onCreate()</code> I setup 3 pending intents to start the same service, each having different extra data to specify the action. I'm creating a notification, and I want to use one pending intent as the click action, one as the dismiss action, and the third is for an alarm.</p>
  
  <pre><code>        Intent iCancel = new Intent(this, BootService.class);
          Intent iAlarm = new Intent(this, BootService.class);
          Intent iDismiss = new Intent(this, BootService.class);
  
          // each will have actions
          iAlarm.putExtra(INTENT_ACTION, INTENT_ALARM_FIRED);
          iCancel.putExtra(INTENT_ACTION, INTENT_CANCEL);
          iDismiss.putExtra(INTENT_ACTION, INTENT_DISMISS);
  
          PendingIntent piCancel = PendingIntent.getService(
                  this,
                  0,
                  iCancel,
                  Intent.FILL_IN_DATA);
  
          mPiAlarm = PendingIntent.getService(this, 0, iAlarm, Intent.FILL_IN_DATA);
  
          PendingIntent piDismiss = PendingIntent.getService(this, 0, iDismiss, Intent.FILL_IN_DATA);
  
          mNotifyBuilder = new NotificationCompat.Builder(this)
                  .setSmallIcon(R.drawable.ic_action_about)
                  .setContentTitle(getString(R.string.app_name))
                  .setContentIntent(piCancel)
                  .setDeleteIntent(piDismiss);
  </code></pre>
  
  <p>The problem is all pending intents seem that have the same intent extra data, so when <code>onStartCommand</code> is launched no matter whether the notification was clicked or dismissed or neither, constant <code>INTENT_CANCEL</code> is received from <code>intent.getIntExtra(INTENT_ACTION)</code></p>
  
  <p>I believe it has something to do with the flags used in <code>PendingIntent.getService()</code>, i'm confused about which to use. I've tried using <code>PendingIntent.FLAG_CANCEL_CURRENT</code>, and <code>UPDATE_CURRENT</code>, neither seem to fix the issue but the result is different, I receive constant <code>INTENT_ALARM_FIRED</code> for every action. </p>
  
  <p>How can I get each pending intent to have its own intent extra data? </p>
  
  <p><strong>Solution</strong></p>
  
  <p>I discovered an exact warning about this scenario right in the <code>PendingIntent</code> doc. <a href="http://developer.android.com/reference/android/app/PendingIntent.html" rel="nofollow">http://developer.android.com/reference/android/app/PendingIntent.html</a></p>
  
  <p>just changed my request codes and it works</p>