journeyapps / zxing-android-embedded

Barcode scanner library for Android, based on the ZXing decoder
https://journeyapps.com/
Apache License 2.0
5.78k stars 1.27k forks source link

How to intentIntegrator to get result form fragment that i run from getSupportFragmentManager commit #711

Open natsirasrafi opened 2 years ago

natsirasrafi commented 2 years ago

in My MainActivtiy button trigger run fragment :

ScanFragment sf = new ScanFragment(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,sf).commit();


in my Fragment Class :

public static ScanFragment newInstance() {
    return new ScanFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_scan, container, false);
    barcodeView = rootView.findViewById(R.id.barcode_view);
    barcodeView.setStatusText("");
    capture = new CaptureManager(getActivity(), barcodeView);
    capture.initializeFromIntent(getActivity().getIntent(), savedInstanceState);
    capture.decode();

    return rootView;
}

if i run fragment with new IntentIntegrator(this).setCaptureActivity(TabbedScanning.class).initiateScan();

is running well , but i want run with :

    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,sf).commit();

because i split my layout with frame layout. when i run with initiateScan() is open new page i want to process result in my mainactivity with intentintegrator