Android 使用 Unicode 的通知区域设置特定消息

Android Notifications Locale specific message with Unicode

您好,我想在通知中使用本地区域语言文本,我可以发送文本的 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);
}

我认为可能有另一种方法可以做到这一点,或者只是一种在特定区域设置中显示通知消息文本的简单方法language.Any提前感谢帮助。

如果您要发送该特定语言的编码 Unicode,请尝试使用此 link

的 commons-lang-2.6 jar

http://java2s.com/Code/Jar/c/Downloadcommonslang26jar.htm

使用:将此行添加到您的通知中class

  StringEscapeUtils.unescapeJava(text)
//here text(Notification text)must be Unicode of that language