【问题标题】:Android JellyBean BigTextStyle Notification not working - HTC One X AT&TAndroid JellyBean BigTextStyle 通知不起作用 - HTC One X AT&T
【发布时间】:2014-08-05 05:19:45
【问题描述】:

我已经实现了 BigTextStyle/InboxStyle 通知,但它显示为在我的 HTC One X AT&T(即 4.1.1)上的 JellyBean(指 Gingerbread、ICS 等)之前显示的普通通知。甚至操作按钮也没有显示。

我已经使用模拟器(使用 JellyBean 4.2)检查了我的代码,并且可以正常工作。

我的 HTC One X 版本似乎没有实现 JellyBean 的新通知系统。

HTC One X AT&T 设备信息

Android Version - 4.1.1 
HTC Sense Version - 4+ 
Software number - 3.18.502.6 710RD 
HTC SDK API Level - 4.63 
HTC Extension version - HTCExtension_Sesnse45_2

源代码

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void showNotificationJB(Reminder reminder, Intent intent) {

    Log.v(TAG, "Showing BigText Notification");

    Notification.Builder builder = new Notification.Builder(this);
    builder.setContentTitle("Ezeetrak Scheduler");

    AdditionalDataStore store = reminder.getStore(); 

    String passedBy = store.optString("passedBy");

    builder.setContentText("Recieved an Event by " + passedBy);
    builder.setTicker("Recieved an Event by " + passedBy);
    builder.setSmallIcon(R.drawable.ic_launcher);

    Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
    inboxStyle.addLine(Html.fromHtml("<b>Name: </b>" + reminder.getEventName()));
    inboxStyle.addLine(Html.fromHtml("<b>Date: </b>" + DateTimeHelper.DateFormat.format(reminder.getEventDate())));
    inboxStyle.addLine(Html.fromHtml("<b>Time: </b>" + reminder.getEventTimeFormatted()));
    inboxStyle.addLine(Html.fromHtml("<b>Sent By: </b>" + passedBy));
    inboxStyle.setBigContentTitle("Ezeetrak Scheduler");

    builder.setStyle(inboxStyle);

    PendingIntent acceptPendingIntent = buildPendingIntent(ReminderActivity.ACTION_ACCEPT, intent, 0);
    PendingIntent rejectPendingIntent = buildPendingIntent(ReminderActivity.ACTION_REJECT, intent, 1);

    builder.setContentIntent(buildPendingIntent(ReminderActivity.ACTION_VIEW, intent, 2));
    builder.addAction(R.drawable.ic_action_accept, "Accept", acceptPendingIntent);
    builder.addAction(R.drawable.ic_action_reject, "Reject", rejectPendingIntent);
    builder.setAutoCancel(false);

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(REMINDER_SHARE_ACTION, builder.build());
}

有人知道为什么它不适用于我的设备吗?

【问题讨论】:

  • 预JB ?这是什么意思?
  • preJB 是指在 JellyBean 之前,正如我们所说的 preHoneycomb 等。
  • 我也有同样的问题。我的是 micromax canvas a74。你有没有得到任何关于这个问题的信息?

标签: android android-notifications android-notification-bar


【解决方案1】:

Android 4.1 中的 BigTextStyle 通知需要两根手指才能展开。

在 Android 4.2 中,只需要一根手指。请参阅视频以供参考。 http://www.youtube.com/watch?v=a6dzMzklEd4

【讨论】:

    【解决方案2】:

    尝试使用NotificationCompat.Builder 而不是Notification.Builder。相应地更改您的代码。这应该可以工作。而且这篇文章的另一个答案是重要

    【讨论】:

    • 4.1 版本的 HTC One X 不支持新的 JellyBean 通知。我已将手机更新到 4.2,现在它支持所有这些通知。这是一篇很老的帖子。
    猜你喜欢
    • 2013-06-09
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多