I'm trying to pass and receive data between two applications, AppA and AppB. In my AppA, I have an AppAActivity.java that has AppAFragment within. I want this fragment to open AppB which has an AppBActivity.java that opens Login fragment, then Payment fragment then Acknowledgement fragment. This Acknowledgement fragment has a "Next" button which upon click, will call the setResult method so that it will now alert the AppAFragment to receive the result. But the onActivityResult method from the AppAFragment responsible for receiving the result, is not being called again.
AppAFragment.java
@Override
public void openUrl() {
Intent intent = getBaseParentActivity().getPackageManager()
.getLaunchIntentForPackage(DataConstants.SAMPLE_RIB_PACKAGE);
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(DataConstants.TRANSACTION_REFERENCE, getLinkWS()
.getTransRef());
intent.putExtra(DataConstants.TRANSACTION_AMOUNT, mAmount.getText()
.toString());
intent.setType(MediaType.TEXT_PLAIN);
startActivityForResult(intent,
DataConstants.CODE_APP_TO_APP_PAYMENT);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK
&& requestCode == DataConstants.CODE_APP_TO_APP_PAYMENT) {
Log.v("Test", "Test");
Toast.makeText(getBaseParentActivity(),
data.getStringExtra(DataConstants.BANK_REFERENCE_NO),
Toast.LENGTH_SHORT).show();
}
}
AcknowledgementFragment.java
@Override
public void buttonNext() {
Intent intent = new Intent();
intent.putExtra(DataConstants.BANK_REFERENCE_NO, infoModel.getBankRef());
getActivity().setResult(Activity.RESULT_OK, intent);
getActivity().finish();
}
Thank you very much!