I call an activity for result:
private static final int CODE_LOGIN = 0;
private static final int CODE_DETAILS = 1;
private void callDetailsActivity() {
Intent switchToDetailsActivity = new Intent(getApplicationContext(), Details.class);
switchToDetailsActivity.putExtra(TAG_ID, details.get(TAG_ID));
startActivityForResult(switchToDetailsActivity, CODE_DETAILS);
}
Now in my Details.class i call to get back to the previous activity:
@Override
public void onBackPressed() {
setResult(RESULT_OK);
super.onBackPressed();
}
And then my onActivityResult()
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == CODE_LOGIN) {
// This is for my other Activity, where the "return" works
}
}
updateOffers();
}
But insead of going back to my previous class the application is closed without any error logs. When I press the home button to go to my previous application, I can go to my application and then I am in my previous activity, but thats definately not the way it is supposed to work.
I also tried not to change onBackPressed()
, or simply write finish()
into onBackPressed()
, but nothing worked.
I haven't set android:noHistory="true"
With my other Activity (which uses excatly the same code), it works perfectly (CODE_LOGIN).
Can somebody help me?
finish()
afterstartActivityForResult
? – JohnettajohnetteCODE_DETAILS
? – Salisbury