在Android系统中,当我的应用程序启动前台服务时,如果用户在设置中关闭了通知权限,该服务真的是前台服务吗?
恐怕没有通知,实际上是后台服务,不能保证完成。
我在我的服务的 onStartCommand 函数中做这样的工作:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "myId")
.setSmallIcon(R.drawable.all_downloads_icon)
.setContentTitle("my title")
.setContentText("you have started a notificaiton")
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
Notification notification = builder.build();
startForeground(110,notification);