0
활동을 확장하여 알림을 만들고 알림이 나타날 때마다 내 앱이 계속 실행됩니다. 매번 같은 활동으로 시작하지 않습니다. 대신 내 앱에서 마지막으로 사용한 활동을 실행합니다. AlarmManager를 통해 특정 날짜/시간에 알림이 시작됩니다. 알림이 내 앱을 시작하지 못하게하려면 어떻게해야합니까? 사용자가 앱을 시작할 때 앱을 실행해야하는데 (그 부분은 정상적으로 작동합니다.) 상태 표시 줄에 처음 알림이 표시되면 앱을 시작하지 않아야합니다. 다음은 알림 코드입니다.Android 알림을 사용하면 알림을 탭하지 않아도 앱이 실행됩니다.
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();
}
}
문제를 어떻게 해결할 수 있습니까?