我正在通过扩展 Activity 创建通知,每次出现通知时,我的应用程序都会不断启动。它不会每次都启动相同的活动。相反,它会启动我的应用程序中最后使用的活动。我的通知正在通过 AlarmManager 在特定日期/时间启动。如何阻止我的通知启动我的应用程序?我需要它在用户点击它时启动应用程序(该部分工作正常),但我不希望它在通知第一次出现在状态栏中时启动应用程序。这是我的通知代码:
public class DisplayReminderNotification extends SherlockActivity {
private Context context = this;
//Grab a handle onto the database and store the name of the reminder.
protected RemindersDAO remindersDAO;
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get the notification ID.
int notifID = getIntent().getExtras().getInt("Reminder_Primary_Key");
String reminderName = getIntent().getExtras().getString("Reminder_Name");
//PendingIntent stores the Activity that should be launched when the user taps the notification.
Intent i = new Intent(this, ViewLocalRemindersDetail.class);
i.putExtra("NotifID", notifID - randomInt);
i.putExtra("notification_tap", true);
displayIntent = PendingIntent.getActivity(this, notifID, i, 0);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(R.drawable.launcher_icon, reminderName, System.currentTimeMillis());
CharSequence from = "Here's your reminder:";
CharSequence message = reminderName;
notif.setLatestEventInfo(this, from, message, displayIntent);
//Fire up the notification.
nm.notify(notifID, notif);
//Destroy the activity/notification.
finish();
}
}
我该如何解决我的问题?