您好我想在通知中使用本地区域语言文本,我可以发送文本的unicode,它可以在设备支持该语言的情况下正常工作。但要支持所有设备我想将类型面(自定义字体)设置为通知文本..我尝试使用RemoteView但没有运气。这里是我使用的通知代码示例..
public void handleNotification(BitMap notificationIcon,String title,String message,){
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.notification);
remoteViews.setTextViewText(R.id.push_subject, title);
message = StringEscapeUtils.unescapeJava(message);
remoteViews.
remoteViews.setTextViewText(R.id.message, message);
//the message is somethisng like unicode "\u092d\u093e\u0930\u0924 \u0915\u0940 \u0930\u093e\u091c\u0928\u0940\u0924\u093f\u0915"
remoteViews.setImageViewResource(R.id.icon, notificationIcon);
final NotificationManager nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
final Notification.Builder builder = new Notification.Builder(context).setTicker(message)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(intent)
.setContent(remoteViews);
Notification n;
if (Build.VERSION.SDK_INT < 16) {
n = builder.getNotification();
} else {
builder.setStyle(new Notification.BigTextStyle().bigText(message));
if (largeBitmap != null) {
builder.setStyle(new Notification.BigPictureStyle()
.bigPicture(largeBitmap).setBigContentTitle(title)
.setSummaryText(message));
}
n = builder.build();
n.priority = Notification.PRIORITY_MAX;
}
n.flags |= Notification.FLAG_AUTO_CANCEL;
nm.notify(0, n);
}
我认为可能有另一种方法可以执行此操作,或者只是以区域设置特定语言呈现通知消息文本的简单方法。任何帮助都要提前感谢。
答案 0 :(得分:0)
如果您要发送该特定语言的编码Unicode,请通过此链接尝试commons-lang-2.6 jar
http://java2s.com/Code/Jar/c/Downloadcommonslang26jar.htm
使用:将此行添加到通知类
StringEscapeUtils.unescapeJava(text)
//here text(Notification text)must be Unicode of that language