Я видел много примеров того, как сделать что-то, что происходит, когда пользователь нажимает на уведомление, но на самом деле я не хочу, чтобы что-то происходило. Если пользователь нажимает на уведомление, я хочу, чтобы уведомление просто исчезло, а пользователь НЕ был никуда.
В моем коде ниже, хотя FLAG_AUTO_CANCEL очищает уведомление из строки состояния, когда пользователь нажимает на мое уведомление, он попадает в «MyActivity».
Как создать уведомление, которое ничего не делает?
Notification notification = new Notification(R.drawable.success, res.getString(R.string.messages_sent), System.currentTimeMillis());
//Define the expanded message and intent
Context context = getApplicationContext();
CharSequence contentTitle = res.getString(R.string.messages_sent_ellipsis);
Intent notificationIntent = new Intent(this, MyActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0 );
notification.setLatestEventInfo(context, contentTitle, mStrSuccessMessage, contentIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
//Pass the notification to the notification manager
mNotificationManager.notify(1, notification);