[Solved] Choosing language at startup


If I understand you correctly you wish to display that activity only when the user runs the app for the first time.

Well, here’s what you can do:

1) Get a handle to a SharedPreference. This is to store if the user has already selected the language or not.

SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);

2) Create a SharedPreferences.Editor

SharedPreferences.Editor editor = sharedPref.edit();

3) Store the information in a key-value

editor.putBoolean("HAS_SELECTED_LANGUAGE", true);

4) Commit the change

editor.commit();

5) Check if ‘HAS_SELECTED_LANGUAGE’ is true in the onCreate() of the activity, if so move on to the next Activity/Fragment/etc

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    ...
    if (sharedPref.getBoolean("HAS_SELECTED_LANGUAGE", false)) {
        //Replace with your action to perform if it is already selected
    }
    ...
}

Also it would be recomended to allow the user to be able to come back and change the language from somewhere else if and when they require.

Hope this solve your problem.

0

solved Choosing language at startup