android - 我的应用程序以编程方式更改本地语言,但通知以设备语言显示其消息
问题描述
我可以以编程方式更改我的应用程序的语言,但 NotificationCompat 保留设备语言。这是一个本地自我通知(不是来自 Firebase)。
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
String id = "id_notif";
String name = "test_notif";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = notificationManager.getNotificationChannel(id);
int importance = NotificationManager.IMPORTANCE_HIGH;
if (mChannel == null) {
mChannel = new NotificationChannel(id, name, importance);
mChannel.enableVibration(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
mChannel.enableLights(true);
mChannel.setShowBadge(true);
notificationManager.createNotificationChannel(mChannel);
}
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, id)
.setSmallIcon(R.drawable.ic_stat_revue)
.setColor(getResources().getColor(R.color.colorAccent))
.setBadgeIconType(BADGE_ICON_SMALL)
.setContentTitle(this.getResources().getString(R.string.title)).setContentText(this.getResources().getString(R.string.content));
Notification notification = mBuilder.build();
notificationManager.notify(magazine.getFilePath().hashCode(), notification);
我使用服务类来下载文件,在下载结束时我会显示通知。
class MagazineDownloadService extends WakefulIntentService
有什么问题?
解决方案
推荐阅读
- django - Firebase FCM 推送通知未在 iOS 12 上显示
- hadoop - Hadoop 升级和公平调度器
- string - 从 ssh 命令设置字符串时未正确转换字符串
- firebase - 带有 FCM 推送通知的 Safari
- python - 用python中的一些文本替换字符串中的日期?
- mysql - 将数据插入数据库时,最后会添加单个空格吗?
- java - 使用 mongo 反应弹簧进行 Webflux 数据检查
- php - 如何在php codeigniter的单列中显示数据库中插入的相同日期记录..?
- reactjs - 如何在 ReactJS 构建中包含 i18next 语言环境文件
- vuejs2 - 使用 Vue CLI 3 创建的 PWA 的 Workbox CacheFirst 策略问题