zxing-android-embedded
zxing-android-embedded copied to clipboard
Configuration.locale change after back from IntentIntegrator.initiateScan()
Greetings and thank you for the good work with this library. I have used it in an app i am working on and I really admire your work with this. I am running into a problem now and I can't find a way to deal with it. In the app I set the configuration.locale to be internal of the app, independent from the device locale. I do it like this:
public void setLocale(String lang) { myLocale = new Locale(lang); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale; res.updateConfiguration(conf, dm); }
It all goes well, the locale changes but than when I do initiateScan() and when camera opens I press the back button, than the strange thing happens, locale gets reverted back to the device default.
IntentIntegrator scanIntegrator = new IntentIntegrator(this); scanIntegrator.setOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); scanIntegrator.initiateScan();
I have tried using other startActivityForResult just to be sure if I should write this to you or not. After trying it did not happen like the case I just described regarding the case with the interaction with your library. Sample other startActivityForResult() :
Intent pickContactIntent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts")); pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); // Show user only contacts w/ phone numbers startActivityForResult(pickContactIntent, 79);
The version of the library I am using is 2.3.0 and the exact dependencies I have are:
compile 'com.journeyapps:zxing-android-embedded:2.3.0@aar'
compile 'com.journeyapps:zxing-android-legacy:2.3.0@aar'
compile 'com.journeyapps:zxing-android-integration:2.3.0@aar'
compile 'com.google.zxing:core:3.2.0'
Do you have any idea why the configuration is changing to the device default configuration(locale in particular) and how can I correct this behavior in my app. Again thank you for the library and for the hard work.
The problem happens when I start another activity from the activity which initiated a scan. In the onActivityResult(...) I have only these lines of code that are related to the library :
//retrieve scan result IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanningResult != null) { //we have a result String scanContent = scanningResult.getContents(); ...
I'm not aware of any code that affects this, although it's not impossible. Will you please test if this still happens with the 3.x branch?
Hi I just tested it with the 3.x and it still happens to me. I even created a new project to test this and it still happens(I created a simple project to get rid of other code and just test this part of the app). I can send you the test project I created so that you won't have to write it yourself.
U can get the test app and import it if you want from here: https://drive.google.com/file/d/0BxtZ7N-Znyracm05RnZiVl9BM0E/view?usp=sharing
Thanks, I'll look into it when I get the chance.
i meet the same issue with u, i solve this with tricky: in lifecycle of activity, onPause(), u save state of current language, then onresume(), u recover expected language.
Still failing :(
There is nothing in this library that touches the device configuration or locale. My best guess is that it must be something else in the app that is causing this.
To debug this further, I'd need a small example application reproducing the issue.
I think your bug may be related to the (final user-developer) locale handling and not for library itself.
I invite you to discover the issue here : https://stackoverflow.com/questions/40634420/android-locale-gets-changed-when-the-orientation-is-changed-to-landscape And as a solution, I highly recommand this one : https://stackoverflow.com/a/42269965/10202308
I am having the same strange behavior with com.journeyapps:zxing-android-embedded:4.3.0 . I have enabled in manifest android:screenOrientation="sensor" . When ever I start up barcode scanner and close it, app does no longer change orientation. It is stuck on the last orientation and only kill/restart helps. As if the barcode scanner overrides screenOrientation parameter.
What helped me was to explicitly set requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR when ever I close the barcode scanner.