I have used this line to check the locale.
String local = context.getResources().getConfiguration().locale.getDisplayCountry();
Toast.MakeText(this,local,Toast.LENGTH_SHORT).show();
It shows Australia (this is where I am). But I need to display different pages based on locale. so what I have done is
if (local=="Australia")
runpage1();
else
runpage2();
But, it doesn't check the local as "Australia", so straight goes to the else line. I tried like
String x;
if (local=="Australia")
x = "1";
else
x="2";
Toast.MakeText(this,x,Toast.LENGTH_SHORT).show();
It shows 2. ( I am trying to write to make it as simple as possible, so nobody gets confused with previously asked questions) Can anybody please suggest me why I am being unable to treat locale as String value ? I have tried using this too.
TelephonyManager teleMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String myCode = teleMgr.getSimCountryIso();
But, same thing, myCode is also cannot be checked as String. Any suggestions will be great.
==
for test only reference..equals()
for check String
values. So you have to compare like this :
String x;
if (local.trim().equals("Australia"))
x = "1";
else
x="2";
Toast.MakeText(this,x,Toast.LENGTH_SHORT).show();