0

MY 应用程序在运行时显示通知。但是当我单击主页按钮(应用程序仍在后台运行)时,通知消失了。在用户点击它之前,我应该怎么做才能保持原样。谢谢

   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);

}
4

1 回答 1

1

不要在 Notification.Builder 中getNotification(); 使用build();

于 2013-10-20T12:42:05.400 回答