Here is the code of my onActivityResult
method:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
String contents = data.getStringExtra("SCAN_RESULT");
if (contents.length() == 26) {
BillBarcode barcode = new BillBarcode(contents);
edtBillId.setText(barcode.extract(BillBarcode.BarcodePart.BillId));
edtPaymentId.setText(barcode.extract(BillBarcode.BarcodePart.PaymentId));
launchService();
} else {
Dialog dialog = new DialogBuilder()
.setTitle(getString(R.string.dialog_title_global_error))
.setMessage(getString(R.string.unknown_barcode))
.build(getActivity());
dialog.show();
}
}
}
The problem is that getString(R.string.dialog_title_global_error)
and getString(R.string.unknown_barcode)
always returns english value while I have Farsi value too and the locale is farsi too.
The problem only exist in this method.
Farsi value:
<string name="unknown_barcode">بارکد قابل استفاده نیست.</string>
English value:
<string name="unknown_barcode">Unknown barcode</string>
EDIT
I have a setting page and set my locale when user selects persian from language page by this code:
String languageToLoad = "fa";
Resources res = context.getResources();
// Change locale settings in the app.
android.content.res.Configuration conf = res.getConfiguration();
conf.locale = new Locale(languageToLoad);