0

I have very wierd problem when translate the app using translations editor.

So I did like the following( https://stackoverflow.com/a/66483251/14446860 ) and it work,I have 3 activies,when I press the button in the first activity it changes the language perfectly for all activities. However when I change the language back to default,the first activity and the third activity are perfect restored,but the second activity(Map activity) textview is not changing,even if I re-install the app and doesn't press the change language button,the second activity is not in the default language..

This is app Manifest:

<activity android:name=".MainActivity"
    android:launchMode="singleTop"
    android:configChanges="locale"
    android:screenOrientation="portrait">

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

</activity>

<activity
    android:name=".MapsActivity"
    android:screenOrientation="portrait"
    android:launchMode="singleTop"
    />

The string file in default folder:

<string name="contact_name">Test:</string>
<string name="destination">Test:</string>
<string name="messageMaps">Test:</string>

The string file in the language folder:

<string name="contact_name">בדיקה:</string>
<string name="destination">בדיקה:</string>
<string name="messageMaps">בדיקה:</string>

When hovering string

The button:

    Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (LANG_CURRENT.equals("en")) {
                changeLang(getApplicationContext(), "iw");
                getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);

            } else {
                changeLang(getApplicationContext(), "en");
            }
            finish();
            startActivity(new Intent(getApplicationContext(), MainActivity.class));

        }
    });

Thank you !

Mr.Goomer
  • 73
  • 7
  • If it's working everywhere else, are you sure that the one place that it's not working isn't using hardcoded strings? If the one place that isn't working isn't referencing these string resources, changing the device language won't help. – Ben P. Mar 05 '21 at 03:20
  • Thanks for replaying Ben ! Yes I am sure its not hardcoded,in addition,when I move other text view that worked on other activity,to maps activity,the textview isn't changing to the default,which means its something about the activity.. – Mr.Goomer Mar 05 '21 at 03:24

1 Answers1

0

So after few hours,I figure out what the problem was.

The problem was I extended FragmentActivity:

public class MapsActivity extends **FragmentActivity** implements OnMapReadyCallback {

And I should have declared AppCompatActivity:

public class MapsActivity extends **AppCompatActivity** implements OnMapReadyCallback {

I knew I would spend hours about something like that ..

Thank you anyway !

Mr.Goomer
  • 73
  • 7