gpt4 book ai didi

android - 从推送通知打开安卓应用

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:30:49 28 4
gpt4 key购买 nike

有个小问题一直困扰着我..

我已经将我的应用程序设置为接收来自 Urban Airship 的推送通知并且一切正常,但是当我点击通知中心的通知时,没有任何反应。

我希望我的应用程序在用户点击推送通知时打开 - 我该怎么做才能实现这一点?

我们一如既往地非常感谢您的帮助。

谢谢

最佳答案

创建一个挂起的 Intent 以启动 Activity 并使用 setLatestEventInfo 在通知中设置它。

例子:

  Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

可以找到更多信息 here

关于android - 从推送通知打开安卓应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10194718/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com