小编Kei*_*n.k的帖子

如何更改 Android 应用程序中的通知设置?

如何以编程方式打开所有这些设置?

我注意到当您安装 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)

java android

6
推荐指数
1
解决办法
1718
查看次数

替代警报管理器 - Android

说真的,在应用程序未运行时发送通知等简单任务的解决方案是什么?(使用小米等自定义操作系统的设备)

设置闹钟后,它会在几分钟等短时间内工作,但不会像几小时那样长时间工作。(尽管它在某些设备上以及在应用程序运行时都可以正常工作)

我已经阅读了数百个线程,但没有人对此有具体的解决方案。推荐的方法都不起作用,我尝试了以下方法:

  1. 警报管理器 + 广播接收器 + 后台服务(适用于某些设备,并非全部)
  2. 警报管理器 + Broadcast Recevier + foregroundService(工作了几次,然后就停止工作了!)我尝试了 intentservice、jobintent 服务,但没有任何效果。
  3. WorkManager(工作无限延迟,有时15分钟有时一小时,有时10小时)
  4. 添加了唤醒锁(没有改变任何东西)
  5. 警报管理器 + IntentService(不起作用)
  6. 为服务设置进程名称(不改变任何东西)
  7. 一些线程和谷歌人说目前没有解决方案。但是我已经看到应用程序可以让它工作!

我读过关于dontkillmyapp 的文章,我知道这个问题。但是我有一个应用程序,它以某种方式设法在非常精确的时间发送通知。它不是像 Whatsapp 这样的著名应用程序。必须有解决方案。

android alarmmanager

5
推荐指数
0
解决办法
72
查看次数

标签 统计

android ×2

alarmmanager ×1

java ×1