gpt4 book ai didi

android - 使用 PendingIntent 和 NotificationManagerCompat 打开 Play Store

转载 作者:太空狗 更新时间:2023-10-29 14:38:27 28 4
gpt4 key购买 nike

有人知道如何使用 NotificationPendingIntent 打开 Play Store 吗?

I want to open Play Store with my app's page. Tried this one so far.

    Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + a.getPackageName()));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(a, 0, i, 0);

NotificationCompat.Builder builder = new NotificationCompat.Builder(a, "update")
.setContentTitle(getStr(a, R.string.notify_update_title))
.setContentText(getStr(a, R.string.notify_update_body))
.setSmallIcon(R.drawable.ic_notif)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent);

NotificationManagerCompat managerCompat = NotificationManagerCompat.from(a);
managerCompat.notify(UPDATE_NOTIF_ID, builder.build());

最佳答案

我的错。我实际上是在一个非常低端的智能手机 API 16 上进行调试,我的 Google Play 遭到破坏(已卸载),因为我需要为 Firebase 更新 Google Play 服务。

The surprising thing is that when i tap the notification it doesn't throw ActivityNotFoundException indicating that Google Play can't be found.

因此在 API 16 中测试了一个小警告。

感谢所有帮助欣赏它的人。

关于android - 使用 PendingIntent 和 NotificationManagerCompat 打开 Play Store,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52213551/

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