android 中的全屏意图到底是什么?

What exactly is full screen intent in android?

我一直在查找什么是全屏意图,但我无法弄清楚它到底是什么。 有一些部分代码示例,但我很少看到任何可见形式的示例。 当我查找全屏意图指的是什么时,我感到很困惑。

据我所见,它似乎弹出了通知栏,但状态栏上没有。当用户按下通知栏时,它会进入全屏。

然而,当我读到这个问题时,我感到困惑。 FullScreenIntent only appears if I clear the notification 这个问题指出,当他清除通知栏时,会出现全屏意图。全屏意图指的是什么? youtube中的视频似乎告诉全屏意图是关于弹出通知栏并通过单击它进入全屏activity,但是当我阅读上面的问题时,我觉得它是分开的来自通知栏。

全屏意图到底是什么?

先来看看Android doc

An intent to launch instead of posting the notification to the status bar. Only for use with extremely high-priority notifications demanding the user's immediate attention, such as an incoming phone call or alarm clock that the user has explicitly set to a particular time. If this facility is used for something else, please give the user an option to turn it off and use a normal notification, as this can be extremely disruptive.

The system UI may choose to display a heads-up notification, instead of launching this intent, while the user is using the device.

this with code example

Your app might need to display an urgent, time-sensitive message, such as an incoming phone call or a ringing alarm. In these situations, you can associate a full-screen intent with your notification. When the notification is invoked, users see one of the following, depending on the device's lock status:

  • If the user's device is locked, a full-screen activity appears, covering the lockscreen.
  • If the user's device is unlocked, the notification appears in an expanded form that includes options for handling or dismissing the notification.

一点解释 回到android的旧时代,如果应用程序有任何紧急情况,您可以直接从后台启动activity。但最终,这已经过时了,您必须 post 通知,以便需要用户交互才能将 activity 带到前台。

但是,如果是紧急任务(例如在拨号器应用程序中接听来电),状态栏通知并不总是最好的用户体验。所以全屏意图在这里很有用。它的工作方式与状态栏通知意图非常相似,但如果用户的设备被锁定,那么您可以全屏显示通知。