Android 通知文本在按状态栏上的“清除”时清除?
在我的应用程序中,我在通知栏上显示通知文本和图标,但我的问题是,当用户按通知栏上的Android 通知文本在按状态栏上的“清除”时清除?,android,android-notifications,android-notification-bar,Android,Android Notifications,Android Notification Bar,在我的应用程序中,我在通知栏上显示通知文本和图标,但我的问题是,当用户按通知栏上的clear时,它会被清除。我想阻止它!?还有一些其他问题: 我想通过不同的活动为我的应用程序创建通知,比如一个在启动时显示“欢迎使用应用程序”,第二个活动显示“请选择”,在“数据发送活动”中显示“成功发送记录” 如何删除应用程序退出时的通知 如何禁用用户在按下通知栏上的“清除”按钮时清除通知 当用户按下状态栏以打开活动时,如何从状态栏中删除通知 有什么帮助吗 我当前的代码 private void Notifica
clear
时,它会被清除。我想阻止它!?还有一些其他问题:
private void Notification(String notificationTickerText, String Title,
String text, Notification nt) {
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.nicon;
CharSequence tickerText = notificationTickerText;
long when = System.currentTimeMillis();
nt = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = Title;
CharSequence contentText = text;
Intent notificationIntent = new Intent(this, frmLogin.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
nt.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notificationManager.notify(1, nt);
}
如果你读了,这可能会回答你所有的问题
它提到您可以使用以下方法防止清除通知:
旗子(无)旗子(清除)
将其添加到标志字段,以指示不应通过“清除通知”按钮清除通知。如果您的通知正在进行中,这一点尤其有用
您可以使用FLAG_AUTO_CANCEL来取消通知,但我不完全确定当与FLAG_NO_CLEAR结合使用时,这是否有效。如果没有,则必须手动修改通知。@Photon通知类有一个字段,因此您可以编写类似于
notification.flags |=notification.FLAG_NO_CLEAR的内容;