Xamarin.Android always getting previously selected Language and not current
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am developing an app in Xamarin.Android and I am fetching the current system language using
CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
It returns the current system language but when I close the app and go to settings and change the language to some another and again open the app then it still returns the old language only. When I re install the app it then shows me the new language.
xamarin xamarin.android
add a comment |
I am developing an app in Xamarin.Android and I am fetching the current system language using
CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
It returns the current system language but when I close the app and go to settings and change the language to some another and again open the app then it still returns the old language only. When I re install the app it then shows me the new language.
xamarin xamarin.android
I created a simple xamarin.android project and tried to get CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; And I found that, when I start the app, then go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language. So the problem is that when you "close" the app, you don't really close it, you just make it unvisible, the Activity is just paused not stopped.
– AbbyWang - MSFT
Nov 19 '18 at 8:34
tried that as well doesn't work, only when I reinstall the app it recognizes.
– Vishwajit Palankar
Nov 19 '18 at 18:02
Where do you write CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;? I put the line in the OnResume() method. And I tried it in the OnCreate method, too, it also works well. I would post my code in the answer and hopes it will help.
– AbbyWang - MSFT
Nov 20 '18 at 2:04
I wrote that insideOnCreate()
afterSetContentView()
and it's not working there.
– Vishwajit Palankar
Nov 20 '18 at 9:51
I also tried writing inside OnCreate() after SetContentView() , it workes all right. Then it may have something to do with other code. Would you please share your full code so that I can reproduce the issue and then try to solve it.
– AbbyWang - MSFT
Nov 20 '18 at 10:14
add a comment |
I am developing an app in Xamarin.Android and I am fetching the current system language using
CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
It returns the current system language but when I close the app and go to settings and change the language to some another and again open the app then it still returns the old language only. When I re install the app it then shows me the new language.
xamarin xamarin.android
I am developing an app in Xamarin.Android and I am fetching the current system language using
CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
It returns the current system language but when I close the app and go to settings and change the language to some another and again open the app then it still returns the old language only. When I re install the app it then shows me the new language.
xamarin xamarin.android
xamarin xamarin.android
asked Nov 16 '18 at 13:04
Vishwajit PalankarVishwajit Palankar
1,90821839
1,90821839
I created a simple xamarin.android project and tried to get CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; And I found that, when I start the app, then go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language. So the problem is that when you "close" the app, you don't really close it, you just make it unvisible, the Activity is just paused not stopped.
– AbbyWang - MSFT
Nov 19 '18 at 8:34
tried that as well doesn't work, only when I reinstall the app it recognizes.
– Vishwajit Palankar
Nov 19 '18 at 18:02
Where do you write CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;? I put the line in the OnResume() method. And I tried it in the OnCreate method, too, it also works well. I would post my code in the answer and hopes it will help.
– AbbyWang - MSFT
Nov 20 '18 at 2:04
I wrote that insideOnCreate()
afterSetContentView()
and it's not working there.
– Vishwajit Palankar
Nov 20 '18 at 9:51
I also tried writing inside OnCreate() after SetContentView() , it workes all right. Then it may have something to do with other code. Would you please share your full code so that I can reproduce the issue and then try to solve it.
– AbbyWang - MSFT
Nov 20 '18 at 10:14
add a comment |
I created a simple xamarin.android project and tried to get CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; And I found that, when I start the app, then go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language. So the problem is that when you "close" the app, you don't really close it, you just make it unvisible, the Activity is just paused not stopped.
– AbbyWang - MSFT
Nov 19 '18 at 8:34
tried that as well doesn't work, only when I reinstall the app it recognizes.
– Vishwajit Palankar
Nov 19 '18 at 18:02
Where do you write CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;? I put the line in the OnResume() method. And I tried it in the OnCreate method, too, it also works well. I would post my code in the answer and hopes it will help.
– AbbyWang - MSFT
Nov 20 '18 at 2:04
I wrote that insideOnCreate()
afterSetContentView()
and it's not working there.
– Vishwajit Palankar
Nov 20 '18 at 9:51
I also tried writing inside OnCreate() after SetContentView() , it workes all right. Then it may have something to do with other code. Would you please share your full code so that I can reproduce the issue and then try to solve it.
– AbbyWang - MSFT
Nov 20 '18 at 10:14
I created a simple xamarin.android project and tried to get CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; And I found that, when I start the app, then go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language. So the problem is that when you "close" the app, you don't really close it, you just make it unvisible, the Activity is just paused not stopped.
– AbbyWang - MSFT
Nov 19 '18 at 8:34
I created a simple xamarin.android project and tried to get CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; And I found that, when I start the app, then go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language. So the problem is that when you "close" the app, you don't really close it, you just make it unvisible, the Activity is just paused not stopped.
– AbbyWang - MSFT
Nov 19 '18 at 8:34
tried that as well doesn't work, only when I reinstall the app it recognizes.
– Vishwajit Palankar
Nov 19 '18 at 18:02
tried that as well doesn't work, only when I reinstall the app it recognizes.
– Vishwajit Palankar
Nov 19 '18 at 18:02
Where do you write CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;? I put the line in the OnResume() method. And I tried it in the OnCreate method, too, it also works well. I would post my code in the answer and hopes it will help.
– AbbyWang - MSFT
Nov 20 '18 at 2:04
Where do you write CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;? I put the line in the OnResume() method. And I tried it in the OnCreate method, too, it also works well. I would post my code in the answer and hopes it will help.
– AbbyWang - MSFT
Nov 20 '18 at 2:04
I wrote that inside
OnCreate()
after SetContentView()
and it's not working there.– Vishwajit Palankar
Nov 20 '18 at 9:51
I wrote that inside
OnCreate()
after SetContentView()
and it's not working there.– Vishwajit Palankar
Nov 20 '18 at 9:51
I also tried writing inside OnCreate() after SetContentView() , it workes all right. Then it may have something to do with other code. Would you please share your full code so that I can reproduce the issue and then try to solve it.
– AbbyWang - MSFT
Nov 20 '18 at 10:14
I also tried writing inside OnCreate() after SetContentView() , it workes all right. Then it may have something to do with other code. Would you please share your full code so that I can reproduce the issue and then try to solve it.
– AbbyWang - MSFT
Nov 20 '18 at 10:14
add a comment |
1 Answer
1
active
oldest
votes
I created a simple xamarin.android project and as I explained in the comment, I put the CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; in the OnResume() method.Then I start the app, go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language.
The code is like this:
public class MainActivity : AppCompatActivity
{
TextView tv;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
}
protected override void OnResume()
{
base.OnResume();
var lang = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
Log.Debug("OnResume", lang);
tv = FindViewById<TextView>(Resource.Id.textView1);
tv.Text = lang;
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338494%2fxamarin-android-always-getting-previously-selected-language-and-not-current%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I created a simple xamarin.android project and as I explained in the comment, I put the CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; in the OnResume() method.Then I start the app, go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language.
The code is like this:
public class MainActivity : AppCompatActivity
{
TextView tv;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
}
protected override void OnResume()
{
base.OnResume();
var lang = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
Log.Debug("OnResume", lang);
tv = FindViewById<TextView>(Resource.Id.textView1);
tv.Text = lang;
}
}
add a comment |
I created a simple xamarin.android project and as I explained in the comment, I put the CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; in the OnResume() method.Then I start the app, go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language.
The code is like this:
public class MainActivity : AppCompatActivity
{
TextView tv;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
}
protected override void OnResume()
{
base.OnResume();
var lang = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
Log.Debug("OnResume", lang);
tv = FindViewById<TextView>(Resource.Id.textView1);
tv.Text = lang;
}
}
add a comment |
I created a simple xamarin.android project and as I explained in the comment, I put the CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; in the OnResume() method.Then I start the app, go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language.
The code is like this:
public class MainActivity : AppCompatActivity
{
TextView tv;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
}
protected override void OnResume()
{
base.OnResume();
var lang = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
Log.Debug("OnResume", lang);
tv = FindViewById<TextView>(Resource.Id.textView1);
tv.Text = lang;
}
}
I created a simple xamarin.android project and as I explained in the comment, I put the CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; in the OnResume() method.Then I start the app, go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language.
The code is like this:
public class MainActivity : AppCompatActivity
{
TextView tv;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
}
protected override void OnResume()
{
base.OnResume();
var lang = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
Log.Debug("OnResume", lang);
tv = FindViewById<TextView>(Resource.Id.textView1);
tv.Text = lang;
}
}
answered Nov 20 '18 at 2:11
AbbyWang - MSFTAbbyWang - MSFT
58916
58916
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338494%2fxamarin-android-always-getting-previously-selected-language-and-not-current%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I created a simple xamarin.android project and tried to get CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; And I found that, when I start the app, then go to the settings app to change the language, then open the app again, it returns the old language. But if I make the app stop by slide it out of the task stack, then open the app again, it returns the new language. So the problem is that when you "close" the app, you don't really close it, you just make it unvisible, the Activity is just paused not stopped.
– AbbyWang - MSFT
Nov 19 '18 at 8:34
tried that as well doesn't work, only when I reinstall the app it recognizes.
– Vishwajit Palankar
Nov 19 '18 at 18:02
Where do you write CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;? I put the line in the OnResume() method. And I tried it in the OnCreate method, too, it also works well. I would post my code in the answer and hopes it will help.
– AbbyWang - MSFT
Nov 20 '18 at 2:04
I wrote that inside
OnCreate()
afterSetContentView()
and it's not working there.– Vishwajit Palankar
Nov 20 '18 at 9:51
I also tried writing inside OnCreate() after SetContentView() , it workes all right. Then it may have something to do with other code. Would you please share your full code so that I can reproduce the issue and then try to solve it.
– AbbyWang - MSFT
Nov 20 '18 at 10:14