gpt4 book ai didi

java - OnMessage 我想打开 Google Play android

转载 作者:行者123 更新时间:2023-11-29 03:39:43 25 4
gpt4 key购买 nike

我收到来自 GCM 的通知,当我收到通知时,我想显示 google play 以安装应用。

我正在尝试这样

    NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);

Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.setData(Uri.parse("market://details?id=com.karya.kot"));
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify( 0, notification);

但是当我点击通知时,它不会去 google play?我做错了什么?

最佳答案

我已经在我的手机上测试了这段代码,它可以正常工作

AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int sb2value = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, "Testomg", System.currentTimeMillis() + 5000);

Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.setData(Uri.parse("market://details?id=com.karya.kot"));
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
notification.setLatestEventInfo(getApplicationContext(), "Google Play", "Download app", intent);

notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);

关于java - OnMessage 我想打开 Google Play android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13738750/

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