I'm trying to localize my app in android studio. All works great unless I open this one specific activity and everything starts going crazy. My app supports English and Arabic language. All strings are available in both resources sets(strings-en.xml and strings-ar.xml) English is the base language in app.
I have 8-10 different activities and fragments. I can open all activities and fragments and everything is localized BUT there is only one activity where everything messes up and after that activity all screens starts showing default localization(en). In this one activity I've a webview and some IntentExtras to deal with and read the urls and title of the activity. Even the default URL and Title that i've defined in the strings.xml is not localized.
Any help is appreciated.
This is a code snippet from WebviewActivity, I'm simply doing startActivity from previous and setting "target" and "url" in IntentExtras.
String title = getText(R.string.BrandName).toString();
target = getIntent().getIntExtra("target", 0);
switch (target){
case 1:
title = getText(R.string.terms).toString();
Url = getText(R.string.terms_url).toString();
break;
default:
title = getText(R.string.default).toString();
Url = getText(R.string.default_url).toString();
break;
}
getSupportActionBar().setTitle(title);
webview_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/offwhite">
<include layout="@layout/app_bar_layout" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:layout_centerInParent="true"
android:id="@+id/noInternetLayout"
android:layout_margin="@dimen/dimen_10">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:tint="@color/grey"
android:src="@drawable/ic_nonet"
android:layout_margin="@dimen/dimen_4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/dimen_4"
android:textAlignment="center"
android:text="@string/noInternetConnection"
android:textStyle="bold|italic" />
</LinearLayout>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_below="@+id/appbar"
android:visibility="gone"/>
<ProgressBar
android:id="@+id/progressBar"
android:progressTint="@color/grey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
/>
</RelativeLayout>