title: Is there a way to kill an activity when PendingIntent is fired?
body: <p>In Android to kill an activity, you just use <code>finish()</code>. But in my case I want to kill the activity when the <code>PendingIntent</code> is fired.</p>
  
  <p>My code is as follow:</p>
  
  <pre><code>Intent intent = new Intent(MainActivity.this, NextActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(Utils.KEY_RECORD_TIME, recordLength);
  
  PendingIntent pintent = PendingIntent.getActivity(MainActivity.this,
          piNumber, intent, 0);
  AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
  alarm.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pintent);
  </code></pre>
  
  <p>If I add <code>finish()</code> beneath, the activity will be killed before the time set up in the <code>AlarmManager</code>.</p>
  
  <p>I want the activity to be visible until the time goes off and kill it. Are there any ways to do this? I did some searches in Stack Overflow, Google but could not find an answer.</p>