我在onReceive
中创建了通知BrodcastReceiver
,点击后再拨打另一位收到通知中显示进度下载的接收方;
点击后我无需关闭通知抽屉。我该怎么办?
@Override
public void onReceive(final Context context, Intent intent) {
Log.v(TAG, "show first notification");
final Notification.Builder mBuilder;
final NotificationManager mNotifyManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder = new Notification.Builder(context);
Intent resultIntent = new Intent(context, SecondReceiver.class);
resultIntent.setAction("second notif");
PendingIntent resultPendingIntent =
PendingIntent.getBroadcast(
context,
0,
resultIntent,
0
);
mBuilder.getNotification().flags |= Notification.FLAG_NO_CLEAR;
mBuilder.setContentIntent(resultPendingIntent)
.setContentText("Tap")
.setSmallIcon(R.drawable.ic_launch)
.setAutoCancel(
mNotifyManager.notify(1, mBuilder.build());
}
答案 0 :(得分:0)
不知道我是否对,但可能是您的问题: -
.setAutoCancel(
mNotifyManager.notify(1, mBuilder.build());
- 按
更改 setAutoCancel(false);
- 添加此行
|= Notification.FLAG_ONGOING_EVENT;
---更新答案---
.setOngoing(true)
- 在您的代码上方添加以上内容仍然无法正常工作然后告诉我,如果是,那么请将我的答案付诸表决谢谢!
-Hopefuly这个帮助。谢谢! - 或者是的,如果这种方式错误,任何人都可以纠正。!