带有“null”的通知待定意向

发布于 2024-10-04 04:27:43 字数 122 浏览 0 评论 0原文

我正在尝试在 Android 中实现通知。

现在我遇到了一个问题,我不想让用户打开任何 ActivityPendingIntent 。我怎样才能做到这一点?

I'm trying to implement notification in Android.

Now I have a problem, I don't want to have a PendingIntent that user will open any Activity. How can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

随梦而飞# 2024-10-11 04:27:43
PendingIntent contentIntent = PendingIntent.getActivity(
    getApplicationContext(),
    0,
    new Intent(), // add this
    PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent contentIntent = PendingIntent.getActivity(
    getApplicationContext(),
    0,
    new Intent(), // add this
    PendingIntent.FLAG_UPDATE_CURRENT);
¢好甜 2024-10-11 04:27:43

以下方法有效并且看起来更简单:

PendingIntent pi = PendingIntent.getActivity(context, 0, null, 0);

在不启动后续活动的情况下发出通知对我来说似乎相当明智 - 例如“该起床了!”

The following works and seems more straightforward:

PendingIntent pi = PendingIntent.getActivity(context, 0, null, 0);

Having a notification without launching a subsequent Activity seems quite sensible to me - eg "Its time to get up!.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文