Q:

How to handle when the device has "do not keep activities" set to ON?

Some android phone users tend to set the "Do Not Keep Activities" flag to true. This causes some trouble where in an activity triggers an intent and listens for a result in onActivityResult. 
A similar scenario is explained in this particular bug in Facebook.
According to the engineers at Faebook, 

This ONLY happens when developer options : "do not keep activities" is set to ON. This means, Android will immediately destroy your activity as soon as you leave it. Even though in normal situation this option should not be set, correct way to develop is with this option set to true so to simulate a POSSIBLE scenario where your activity gets destroyed.

How should this situation be handled?

A:

You need onSaveInstanceState() and onRestoreInstanceState():
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putBoolean("bool", true);
    savedInstanceState.putDouble("double", 1.9);
    savedInstanceState.putInt("int", 1);
    savedInstanceState.putString("string", str);
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    boolean flag = savedInstanceState.getBoolean("boolean");
    double count = savedInstanceState.getDouble("double");
    int size = savedInstanceState.getInt("int");
    String title = savedInstanceState.getString("string");
}

