android - setFullScreenIntent 第二次不起作用

标签 android android-activity notifications android-notifications

我在 android 中有一个应用程序,在某些情况下我想将一个 Activity 带到前台。我为此使用 NotificationManager。这是我的代码。问题是,第一次成功地将 Activity 带到前面,但后来却没有。此外,此代码是从服务运行的。

Intent notificationIntent = new Intent(context, MainActivity.class);
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

            NotificationCompat.Builder mBuilder =
                        new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentIntent(contentIntent)
                        .setContentTitle("Bring me front!")
                        .setContentText("Bring me!!! BRING!!!")
                        .setFullScreenIntent(contentIntent, true);

            NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(0, mBuilder.build());

最佳答案

NotificationManager 具有(未记录的)行为,如果您发布与已激活通知的 ID 匹配的新通知,它将忽略 fullScreenIntent 字段。

关于android - setFullScreenIntent 第二次不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17616631/

相关文章:

java - 读取 res/raw 中的文本文件,非常慢。使用缓冲阅读器

java - 如何从字符串请求生成序列?

java - notifyDataSetChanged() 在 ListFragment 中不起作用

android - 在android中读取xml文件 - 解析

java - 来自 Java 的 Windows 10 通知

objective-c - Mac OS X NSUserNotificationCenter 通知获取取消事件/回调

Android应用程序和Activity之间的静态存储

android - 为什么在以下情况下不调用 "onPause"?

android - 如何随着 Activity 暂停 TextToSpeech?

javascript - 我的网站仅在登录层上有 https。可以为我的网站实现服务 worker 来实现 chrome 通知吗