在您的应用程序类中,您可以保留当前显示的通知 ID 的引用及其信息。您可以在那里检测语言变化onConfigurationChanged(Configuration newConfig)
并更新您的通知。
public class App extends Application {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//update your notifications there is no need for a Thread
}
}
另一种解决方案(真实的)
为区域设置更改添加接收器
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//retrieve the list of notifications
//update them (no need for thread)
}
}
添加到您的清单:
<receiver android:name="MyReceiver">
<intent-filter>
<action android:name="android.intent.action.LOCALE_CHANGED">
</action>
</intent-filter>
</receiver>