Prevent activity from being destroyed

Diego picture Diego · May 2, 2012 · Viewed 12.7k times · Source

I'm sending an intent to the camera from an activity that I call like this:

 Intent testphoto = new Intent(Dashboard.this,CameraHandler.class);
 startActivity(testphoto);

In the CameraHandler class I call the camera:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(intent, 0);

But before onActivityResult gets called in the CameraHandler class the activity is destroyed. Is there anyway to prevent this?

FOUND THE ANSWER: I had noHistory="true" in my AndroidManifest and that made the OS destroy the activity before the result.

Answer

Omaraf picture Omaraf · Nov 17, 2013

Be sure you don't have the "Don't keep activities" Developer setting on, as it will destroy the activity you are leaving.