Saturday, 7 September 2013

Android: onActivityResult in fragment not called

Android: onActivityResult in fragment not called

Found numerous post regarding my issue but none of them worked out for me.
I have a fragment from where I have to call startActivityForResult() on a
textview click. From there, an activity will open up where user will fill
some data and submit it to database. From there, I have to pass an intent
containing the result code. But the onActivityResult() in fragment is not
get called.
Code from my fragment
Intent in = new Intent(getActivity(), NetBarrelActivity.class);
in.putExtra(AppUtility.ORDER_ID, orderDAO.getOrderNum());
in.putExtra(AppUtility.TICKET_ID, 2);
startActivityForResult(in, AppUtility.REQUEST_CODE);
Code from my activity
Double NetBarrels = crudeNetCalculator(GrossBarrels,
ProductObsTemp, ProductObsGravity, ProductBSW);
db.updateTank(OrderID, TicketTypeID, CarrierTicketNum,
TankNum, TankTypeID, ProductObsTemp,
ProductObsGravity, ProductBSW, GrossBarrels,
NetBarrels);
Intent in = new Intent();
setResult(RESULT_OK, in);
finish();
So, how do I send intent back to my fragment with result code?

No comments:

Post a Comment