using initiateScan() in android.support.v4.app.Fragment is not invoking onActivityResult()
See original GitHub issueI tried the following inside the android.support.v4.app.Fragment:
IntentIntegrator integrator = new IntentIntegrator(getActivity());
The constructor for the Fragment is only available for the native Fragment provided by the SDK in the device not the support-v4 or package. After deeper investigation i find out that the REQUEST_CODE: https://github.com/zxing/zxing/blob/6c522f127a0ac40b2e14518528c9547018e044b2/android-integration/src/main/java/com/google/zxing/integration/android/IntentIntegrator.java#L112
value seems the issue. It prevents later in the FragmentActivity here: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/support/v4/app/FragmentActivity.java/#150 that the index is not 0. Then it traverses through all fragments and invokes onActivityResult() properly. I set a breakpoint with the debugger and modified the REQUEST_CODE and it works. I haven’t tested it if this implies other problems.
Would be nice to have your feedback. Thank you very much for reading.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:2
- Comments:13 (3 by maintainers)
Top GitHub Comments
The problem is that there is no constructor for
IntentIntegrator
that takesandroid.support.v4.preference.PreferenceFragment
. Could you implement such a constructor?The code in the second comment should work, but I’d rather not use that ugly hack.
I suppose I’m asking whether the “312” is the necessary change, or calling
startActivity
on theFragment
? I would not expect that the value matters as long as its top 16 bits are 0 (these are reserved from Android 3.x onward IIRC). I also expect that you can use the constructor forFragment
if you need its method invoked. Do we need a different, other constructor?