I know that this question may be asked someone else but I can't find a solution that worked for me. Basically I have a fragment with one button. When user press that button new activity is opened (that activity just scans qr code) and I want to pass scan result back to my fragment. So basically
public class UiFragment extends Fragment implements ServiceCallBack {
    // tons of code
    scanButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), ScanActivity.class); // start scan activity
                startActivity(intent);
            }
        });
}
public class ScanActivity extends AppCompatActivity {
   // lots of code
     public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
        if (scanResult != null) {
            String result = scanResult.getContents();
            if(result != null && result.length() > 0){
                // now I want to go back to my previous fragment and pass result
            }
        }
        finish();
    }
}
Please note that I want activity to fragment communication! I have tried to use interface, however that doesn't worked for me. Is it possible to do that?
 
    