error when trying to change APP language in some device
Gerson Jose Rodriguez Quintero
51
Reputation points
good afternoon I'm trying to force my application to run in es-MX language through the following code, in mainActivity
protected override void OnResume()
{
base.OnResume();
try
{
var userSelectedCulture = new CultureInfo("es-MX");
Thread.CurrentThread.CurrentCulture = userSelectedCulture;
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
}
oncreate
try
{
string cultureName = "es-MX";
var locale = new Java.Util.Locale(cultureName);
Java.Util.Locale.Default = locale;
var configg = new Android.Content.Res.Configuration { Locale = locale };
BaseContext.Resources.UpdateConfiguration(configg, BaseContext.Resources.DisplayMetrics);
}
catch (Exception e)
{
Console.WriteLine(e);
}
the code works on some devices but on others, it generates this error
System.Reflection.TargetInvocationException:* 'Exception has been thrown by the target of an invocation.'
Can you help me with a solution?
thxs
Developer technologies .NET Xamarin
5,380 questions
Sign in to answer