I have looked at several examples and I cant find what I am doing wrong.
my onActivityResult() method is not being called on my activity;
TransactionFormActivity
is starting up a new activity called VehicleSearchActivity
which has a customListAdapter.when I click on an item in that adapter I want to pass a value back to the TransactionFormActivity
.
here is the code from my two activities:
Code in Custom List Adapter onClick()
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(context, TransactionFormActivity.class);
i.putExtra("VehicleId", rowItem.VehicleId);
i.putExtra("VehicleReg", rowItem.Registration);
context.startActivityForResult(i,0);
context.finish();
}
}
and here is the code in The TransactionFormActivity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
vehicleId = data.getIntExtra("VehicleId", 0);
vehicleReg.setText(data.getStringExtra("VehcilceReg"));
}
}
}
When I debug and put break points, my code in the onClickListener is being run. However the app returns to the TransactionFormActivty and the OnActivityResult()
method is never called?
What could I be doing wrong.