在Android

时间:2016-06-01 15:28:40

标签: android android-activity push-notification android-notifications

我正在使用此代码向代码显示用户通知:

 Intent intent = new Intent(this, this.getClass());
    PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.icon)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.icon))
            .setContentTitle("Notification!")
            .setContentText("Hello word")
            .setContentIntent(pi)
            .setDefaults(NotificationCompat.DEFAULT_ALL)
            .setPriority(NotificationCompat.PRIORITY_MAX);

    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(0, mBuilder.build());

这是juste在通知屏幕中添加通知(以及状态栏中我的应用程序的图标)

但是如何在屏幕上预览此通知?

0 个答案:

没有答案