Android 通知栏Notification 悬浮通知栏

NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder builder = new Notification.Builder(this);
        Intent intent = new Intent(Main2Activity.this,ReceiveMailActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        builder.setContentIntent(pendingIntent);
        builder.setSmallIcon(R.drawable.logo);
        builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.logo));
        builder.setAutoCancel(true);
        builder.setContentTitle("悬挂式通知");
        builder.setFullScreenIntent(pendingIntent, true);
        mNotificationManager.notify(2, builder.build());

 亲测可用

猜你喜欢

转载自blog.csdn.net/qq_35644307/article/details/85304874