即使強制關閉我的應用程序,我的通知也不會消失。即,當我打開多任務窗口並將其刷掉時,我的持續通知不會消失。即使我強制關閉我的應用程序,我的通知也不會消失
這是我的通知填入方法:
public void populateNotification(Boolean bool) {
int notifyID = 1;
notificationBuilder = new NotificationCompat.Builder(MainActivity.this);
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher_round);
notificationBuilder.setContentText("Set Content Text");
notificationBuilder.setContentTitle("Set Content Title");
notificationManager = (NotificationManager) getBaseContext().getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
if (bool) {
notificationManager.notify(notifyID, notificationBuilder.build());
} else {
notificationManager.cancel(notifyID);
}
這是我的onDestroy方法:
`
public void onDestroy() {
if (cameraAPIself != null) {
cameraAPIself.destroyCamera();
}
if (cameraAPI2self != null) {
cameraAPI2self.destroyCamera();
}
populateNotification(false);
super.onDestroy();
}`
基本上,我的應用程序所做的就是顯示通知時,閃光燈亮。但是,當我強制關閉我的應用程序ie。當閃光燈開啓(當通知被填充時),通知不會消失,因爲不需要通知,因爲應用程序不再活動。任何人都可以在此指導我。
非常感謝很多人,作品像一個魅力:) –
非常歡迎你:) –