Doesn't work inside Fragments
See original GitHub issueThe problem is not avoidable with IntentIntegrator.initiatescan(getActivity())
because it wouldn’t trigger Fragment onActivityResult
.
Current workaround:
Intent i = IntentIntegrator.createScanIntent(getActivity(), null, null);
i.setAction(Intents.Scan.ACTION);
i.putExtra("RESULT_DISPLAY_DURATION_MS", 0L);
startActivityForResult(i, IntentIntegrator.REQUEST_CODE);
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Fragment Inside Fragment - android - Stack Overflow
Fragment Inside Fragment ... means fragment or inner fragments are already added and I am trying to add them again, anybody has idea...
Read more >Creating and Using Fragments | CodePath Android Cliffnotes
A Fragment is a combination of an XML layout file and a java class much like an Activity . · Using the support...
Read more >Fragments inflated via AndroidViewBinding don't work as ...
If you use FragmentContainerView , the fragment appears the first time the container is inflated, but later times it does not appear.
Read more >Fragment | Android Developers
It is strongly recommended that subclasses do not have other constructors with ... It is the first place application code can run where...
Read more >7 Common Mistakes Easily Made with Android Fragment
With this in place, the data object will only be created once every fragment creation. It will not be recreated when we pop...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In this fork I added some methods so that you can do the following:
This takes care of most of the boilerplate configuration, but allows you do customize properties on the intent further as you want. It should also work better for usage from a Fragment.
For more methods, see the IntentIntegrator source.
Thanks for your suggestion. My problem is scanning QRCode from DialogFragment. So I did it like this:
IntentIntegrator.forSupportFragment(this).setPrompt(“Scan a barcode or QRCode”).initiateScan();
This is worked for me.