IntentIntegrator ii = new IntentIntegrator( getActivity() );
ii.initiateScan( IntentIntegrator.QR_CODE_TYPES );
activity.startActivityForResult(intentScan, REQUEST_CODE);
import android.support.v4.app.Fragment;
....
private Fragment fragment;
public IntentIntegrator(Fragment fragment) {
this(fragment.getActivity());
this.fragment = fragment;
}
...
public AlertDialog initiateScan(Collection<String> desiredBarcodeFormats) {
...
if(fragment==null) {
activity.startActivityForResult(intentScan, REQUEST_CODE);
}
else {
fragment.startActivityForResult(intentScan, REQUEST_CODE);
}
return null;
}
Please find a proposal patch as an attachment.
Hartmut: you could try to apply it to your local copy.
2012/1/9 Hartmut <hartmu...@ti-wmc.nl>:
A new much simpler patch is attached.
Made IntentIntegrator non-final, re-factored-out the call to
startActivityForResult(...) as a protected method. Sub-classed the
integrator to support Android 3.0 Fragments, and Android Support v4
library.
Hartmut seems to consider this an appropriate solution.
2012/1/9 Lachezar Dobrev <l.do...@gmail.com>:
If the user needs to copy the integrator he can choose to copy the
needed classes only depending on their framework choices.
For those who choose to reference a .jar library the integrator can
be built in 3 (or 4) different flavours: «legacy», «honeycomb», and
«compatibility». Possibly a «complete» flavour can be build, but I see
no reason behind it. Every flavour .jar would contain only the
required classes.
The reason for the separation is my willingness to provide users
with the ability to check-out newer versions from the Subversion
repository without the need to modify any part of the code (so that
updates are easy on them).
Currently in Eclipse I have both the Android Honeycomb .jar and the
v4 compatibility .jar and it compiles all classes without a problem.
2012/1/18 Sean Owen <sro...@gmail.com>: