Adrian J Adrian J - 1 year ago 86
Android Question

StartActivityForResult, but activity finishes

I am trying to use Adobe Image Edit SDK to edit a photo then redirect to another activity, from my custom camera activity.

This works from another activity, simply by creating the Image edit Intent, using startActivityForResult, then treating the "Done" callback in said activity, in the method onActivityResult.

Intent imageEditorIntent = new AdobeImageIntent.Builder(mContext)
.withOutput(new File(mLastSavedFilePath))
startActivityForResult(imageEditorIntent, 2);

and then

public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == 2) { // i get here

However, when I do this from my Custom Camera Activity, the activity ends when I click "done" in the image edit sdk (its onDestroy is called) before it gets to the result

Intent intent = FileUtils.getInstance().SavePhoto(data, mContext); //this returns an AdobeImageIntent
startActivityForResult(intent, 1);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
//this never gets called, because activity finishes, but why?
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {

So why is the activity finishing, if the other one does not?

Answer Source

Turns out this was my fault, I did not notice I had android:noHistory="true" in the manifest for the second activity

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download