如何以编程方式打开所有这些设置?
我注意到当您安装 WhatsApp 时,它们一开始都处于开启状态(请看下图)。
但是我找不到以编程方式打开它们的方法。
这是我发送通知的方式:
private void sendNotification(Intent intent){
Context context = NotificationService.this;
//open the activity after the notification is clicked
Intent intent1 = new Intent(getApplicationContext(),MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent1, 0);
Notification.Builder builder = new Notification.Builder(context)
.setTicker("Notification")
.setContentTitle("Important Message")
.setContentText("This is an example of a push notification using a Navigation Manager")
.setSmallIcon(R.drawable.ic_add)
.setContentIntent(pIntent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
//These are necessary for the notification to pop up
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O){
builder.setPriority(Notification.PRIORITY_MAX); …Run Code Online (Sandbox Code Playgroud) 说真的,在应用程序未运行时发送通知等简单任务的解决方案是什么?(使用小米等自定义操作系统的设备)
设置闹钟后,它会在几分钟等短时间内工作,但不会像几小时那样长时间工作。(尽管它在某些设备上以及在应用程序运行时都可以正常工作)
我已经阅读了数百个线程,但没有人对此有具体的解决方案。推荐的方法都不起作用,我尝试了以下方法:
我读过关于dontkillmyapp 的文章,我知道这个问题。但是我有一个应用程序,它以某种方式设法在非常精确的时间发送通知。它不是像 Whatsapp 这样的著名应用程序。必须有解决方案。