如何检查的通知,或在Android主屏幕仪表板应用程序图标,用户点击的活动是否推出
如何检查的通知或从Android的用户点击主屏幕仪表板应用程序图标的活动是否正式启动。有没有告诉,这项活动推出,由于用户点击通知任何参数。
how to check whether the activity was launched from notification or from the user click on home screen dashboard app icon in android. Is there any parameters that tells that this activity was launched due to user clicked on notification..
目前市场上已经有关于这一主题的几个问题:
There already were several questions on this topic:
- detecting应用程序启动的 在家中或记录
- Determine如果应用程序从启动 主屏幕?
作为主屏幕的部分,据我所知是没有办法来检测。
As of the home screen part, as far as I know there is no way to detect that.
不过,您可以检测从通知图标的活动是否启动:
However, you can detect whether your activity is launched from the notification icon:
在设置您的通知,你把一个额外的到它的 PendingIntent
,说 fromNotification:布尔
。
在您的主要活动的的onCreate
方法,你检查的目的的临时演员,如果(有任何和)的 fromNotification
是其中它们与值真
,比你知道它已被clikcing通知图标上调用。
When setting up your notification, you put an extra into it's PendingIntent
, say fromNotification: boolean
.
In your main activity's onCreate
method you check the intent's extras, and if (there are any and) the fromNotification
is among them with the value true
, than you know it has been invoked by clikcing on the notification icon.