在通知点击打开特定应用

时间:2018-04-23 19:52:43

标签: android firebase firebase-notifications

我在通知中收到了包名,我想在点击通知后在Play商店中打开该特定应用。如何处理?

1 个答案:

答案 0 :(得分:1)

您可以简单地使用隐含意图:

       NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(icon, message, when);
        Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + PACKAGENAME))
        PendingIntent intent = PendingIntent.getActivity(context, 0,
                notificationIntent, 0);
        notification.setLatestEventInfo(context, title, message, intent);
        notificationManager.notify(0, notification);