Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
New Contributor
Posts: 2
Registered: ‎04-24-2013
My Device: BB Playbook 2.1
My Carrier: t-mobile

Porting android to BB Change of language problems...

Hi, I developed multilanguage app for Android, so i Need to port to BB PlayBook and BB10

I am testing the app on the playbook and I have this problem:

It is about english and arabic language, It seems like when I change the language, only then the arabic is shown correctly and the correct strings.xml.

The next run of the app it reads the set language from the SharedPreferences file and it sets the language in the onCreate in mainActivity, aligns the text to the right BUT displays the english strings.xml. 

In the mainActivity is used the same code that i use for the changing the language in languageActivity.

 

Now if I change it to ar again manually it will change!!!!!!

and that is repeating every time I run the app.


Here is the code for changing the language:

SharedPreferences mSharedPrefs = getSharedPreferences("xmlFile",Context.MODE_PRIVATE);
Configuration conf = getResources().getConfiguration();
String language = mSharedPrefs.getString("language", "en"); // "en" is the default value if no other found 
Locale locale = new Locale(language);
Locale.setDefault(locale);
conf.locale = locale;
this.getBaseContext().getResources().updateConfiguration(conf, getResources().getDisplayMetrics());

SharedPreferences.Editor mPrefsEditor = mSharedPrefs.edit();

mPrefsEditor.putString("language", language);
mPrefsEditor.commit();

Is there someone that has any kind of idea why is this happening???

 

I would be very gratefull 

New Contributor
Posts: 2
Registered: ‎04-24-2013
My Device: BB Playbook 2.1
My Carrier: t-mobile

Re: Porting android to BB Change of language problems...

[ Edited ]

ANYONE???!?

New Developer
Posts: 9
Registered: ‎06-23-2013
My Device: BB Z10
My Carrier: STC

Re: Porting android to BB Change of language problems...

----------global class so that can be called from any activity

class GlobalClass{
SharedPreferences preferences;
 

public static void ChangeLanguage(){
preferences = PreferenceManager.getDefaultSharedPreferences(context);
String language = preferences.getString("language", "ar");
Locale appLoc = new Locale(language );
Locale.setDefault(appLoc);
Configuration appConfig = new Configuration();
appConfig.locale = appLoc;
c.getResources().updateConfiguration(appConfig, c.getResources().getDisplayMetrics());
}
}

 

----------Activity class
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 GlobalClass.ChangeLanguage();
}