NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle(description.getTitle())
.setAutoCancel(false);
NotificationManager notificationManager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notificationCompat=builder.build();
notificationManager.notify(MY_ID,notificationCompat);
startForeground(MY_ID,notificationCompat);
使用上述代碼在後臺運行服務。但是,當活動關閉,服務調用的onDestroy如何在NotificationCompat.Builder中使用startForeground?
「不工作」?什麼不起作用? –
當顯示屏關閉服務電話onDestroy –