由网友(别深拥一个梦)分享简介:我得到通知,GCM,当我得到通知,我想表明谷歌播放安装应用程序。I get notification from GCM, When i get notification, i want to show google play to install app.我试着像这样NotificationManager noti...
我得到通知,GCM,当我得到通知,我想表明谷歌播放安装应用程序。
I get notification from GCM, When i get notification, i want to show google play to install app.
我试着像这样
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);
但是当我点击的通知,它不是将谷歌玩?我做错了什么?
But when i click the notification, its not going to google play? What i did wrong?
推荐答案
我已经测试了这个code。在我的手机,它是工作
I have tested this code in my mobile and it is working
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);
相关推荐
最新文章