我创建了一个简单的Android应用程序(https://github.com/soleimani/android-notification-locale)来通知文本,它有两个按钮,一个加载默认的区域设置文本和图标,另一个加载" fa"语言环境。图像,通知标题和通知文本都尊重区域设置,但通知图标来自默认区域设置(" en")
Button en = (Button) findViewById(R.id.buttonEN);
en.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
conf.locale = new Locale("en");
res.updateConfiguration(conf, dm);
NotificationCompat.Builder overdueNotification = new NotificationCompat.Builder(getApplicationContext())
.setContentText(getText(R.string.notification_service_content_text))
.setSmallIcon(R.drawable.ic_stat);
overdueNotification.setContentTitle(getText(R.string.notification_service_content_title));
notificationManager.notify(1, overdueNotification.build());
image.setImageResource(R.drawable.ic_stat);
image.setImageResource(R.drawable.ic_launcher);
}
});
Button fa = (Button) findViewById(R.id.buttonFA);
fa.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
conf.locale = new Locale("fa");
res.updateConfiguration(conf, dm);
NotificationCompat.Builder overdueNotification = new NotificationCompat.Builder(getApplicationContext())
.setContentText(getText(R.string.notification_service_content_text))
.setSmallIcon(R.drawable.ic_stat);
overdueNotification.setContentTitle(getText(R.string.notification_service_content_title));
notificationManager.notify(2, overdueNotification.build());
image.setImageResource(R.drawable.ic_stat);
image.setImageResource(R.drawable.ic_launcher);
}
});