0

I have three activities Login Activity , Complaint Activity and Customer Details Activity.

A) Login Activity : The Login activity orientation is Portrait

B) Complaint Activity : The Complaint activity orientation is Landscape

C) Customer Details Activity : The Customer Details Activity orientation is Portrait

the flow is A => B => C

I use two languages in app English and Marathi.

once I selected Marathi language for first Activity(for entire app). i.e Login Activity

the Other preceding activity should follow same locale.

but when activity B) Complaint Activity start in landscape mode, it change to default locale i.e English.and app continue in English Language.

How should i set The selected locale for entire app even if the activity changes its orientation.

My Try

1) Adding

android:configChanges="locale|orientation|screenSize"

in Manifest File for every Activity

2) Passing Language in intent and retrieving other activity and setting up locale

Login Activity

  Intent i = new Intent(Login_Activity.this, Complaint_List_Activity_2.class);
            i.putExtra("lang",lang );// lang ="language Code"
            startActivity(complaint_list_activity_intent);
            finish();

Complaint Activity

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_compalint__list__activity_2);
        Intent pre_intent = getIntent();
        lang = pre_intent.getStringExtra("lang");
        Configuration config = new Configuration();
        config.locale = new Locale(lang);
        }

Please explain ,where should i write the code to set the locale in Complaint Activity and how

1 Answers1

0

In onCreate() of Complaint Activity because it should be changed once.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79