Android 单击主页按钮时通知消失
我的应用程序在运行时显示通知。但当我单击home按钮(应用程序仍在后台运行)时,通知消失。 我应该怎么做才能保持它的原样,直到用户点击它。 谢谢Android 单击主页按钮时通知消失,android,notifications,Android,Notifications,我的应用程序在运行时显示通知。但当我单击home按钮(应用程序仍在后台运行)时,通知消失。 我应该怎么做才能保持它的原样,直到用户点击它。 谢谢 不要使用getNotification()改为使用build()在Notification.Builder中您的代码在哪里?让我们看看你试过什么 private void showNotification() { // The PendingIntent to launch our activity if the user select
不要使用
getNotification()代码>改为使用build()代码>在Notification.Builder中您的代码在哪里?让我们看看你试过什么
private void showNotification() {
// The PendingIntent to launch our activity if the user selects this
// notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
serviceIntent, 0);
Notification notification = new Notification.Builder(this)
.setTicker("Accelormeter app").setContentTitle("Acc")
.setContentText("Notification content.")
.setSmallIcon(R.drawable.noti_icon).setContentIntent(contentIntent)
.getNotification();
// Send the notification.
mNM.notify(0, notification);
}