question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't work inside Fragments

See original GitHub issue

The 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:closed
  • Created 9 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
rkistnercommented, May 8, 2014

In this fork I added some methods so that you can do the following:

Intent intent = IntentIntegrator.createScanIntent(this);
startActivityForResult(intent, IntentIntegrator.REQUEST_CODE);

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.

0reactions
aungtuntuncommented, Sep 8, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found