单击主页按钮时通知消失

时间:2013-10-20 12:26:59

标签: android notifications

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

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

}

1 个答案:

答案 0 :(得分:1)

请勿在{Notification.Builder

中使用getNotification();代替build();
相关问题