如何让我的通知在Android Oreo中变得紧凑?

时间:2017-09-27 07:52:20

标签: android android-8.0-oreo

我已经通知我的应用程序,我的应用程序的API范围是21-26。我花了两个小时看这个,我无法找到解决方案。我可能一直在寻找错误的东西,但这正是我所寻找的:

Compact Notification

这是我的通知管理器代码:

    @TargetApi(26)
private void runNotificationManager() {
    NotificationManager mNotificationManager = 
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    id = "auto_birthday_01";
    CharSequence name = getString(R.string.channel_name);
    String description = getString(R.string.channel_description);
    int importance = NotificationManager.IMPORTANCE_MIN;
    NotificationChannel mChannel = new NotificationChannel(id, name, importance);
    mChannel.setDescription(description);
    mChannel.enableVibration(false);
    mNotificationManager.createNotificationChannel(mChannel);

}

这是我的通知代码:

  private void runNotification(NotificationManager notificationManager) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, id);
    builder.setSmallIcon(R.drawable.ic_stat);
    Intent intent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this,
    0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);
    builder.setLargeIcon(
    BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round));
    builder.setContentTitle("Title!");
    builder.setContentText("Open.");
    builder.setOngoing(true);
    notificationManager.notify(1, builder.build());
}

我得到的只是标准通知。谢谢。

0 个答案:

没有答案