即使强制关闭我的应用程序,我的通知也不会消失。即,当我打开多任务窗口并将其刷掉时,我的持续通知不会消失。即使我强制关闭我的应用程序,我的通知也不会消失
这是我的通知填入方法:
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。当闪光灯开启(当通知被填充时),通知不会消失,因为不需要通知,因为应用程序不再活动。任何人都可以在此指导我。
非常感谢很多人,作品像一个魅力:) –
非常欢迎你:) –