Viv*_*wal 4 android android-notifications android-notification-bar
我已经实现了一个BigTextStyle/InboxStyle通知,但它显示为正常的通知,它显示在我的HTC One X AT&T(4.1.1)上的JellyBean(在Gingerbread,ICS等中)之前.甚至动作按钮也未显示.
我用模拟器检查我的代码(使用JellyBean 4.2),这是有效的.
看起来我的HTC One X版本没有实现JellyBean的新Notification System.
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
Run Code Online (Sandbox Code Playgroud)
源代码
@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());
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么它不能用于我的设备?
Android 4.1中的BigTextStyle通知需要两个手指才能展开它.
在Android 4.2中,只需要一根手指.请参阅视频以供参考.http://www.youtube.com/watch?v=a6dzMzklEd4
| 归档时间: |
|
| 查看次数: |
1731 次 |
| 最近记录: |