我的通知

时间:2017-05-11 07:27:16

标签: android notifications

我的应用程序应该不时发出通知。我的智能手机的Android版本是棒棒糖5.1。我的手机是小米。通知有什么问题:

1.大图标和小图标没有显示但是在KitKat中,android版本的小图标工作得很好,并且在大图标的名称中,小图标正在其中使用。

2.Notification风格未被更改。(我已尝试过NotificationCompat.BigTextStyle)

这是我的代码:

// TO SET LARGE ICON
    Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(),
            R.drawable.ic_stat_onesignal_default);
// ASSIGN INBOX STYLE NOTIFICATION
    NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();
    bigText.bigText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.");
    bigText.setBigContentTitle("some title");
    bigText.setSummaryText("Author: unknown");
// NOTIFICATION
    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setTicker("Alert!")
                    .setLargeIcon(largeIcon)
                    .setSmallIcon(R.drawable.ic_stat_small24)
                    .setContentTitle("some title")
                    .setContentText(blah blah)
                    .setStyle(bigText);
// Gets an instance of the NotificationManager service
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

//to post your notification to the notification bar
mNotificationManager.notify(0, mBuilder.build());

0 个答案:

没有答案