Dany Y
Dany Y

Reputation: 7031

onActivityResult is never called in TabActivity

I know there are tons of the same questions, but still OnActivityResult is not being called.

This is my code

Activity A:

        Intent i = new Intent();
        Bundle b = new Bundle();
        b.putString(ActivityB.LINK, ad.getLink());
        i.putExtras(b);
        i.setClass(this, ActivityB.class);
        startActivityForResult(i, 0);

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        /*handling of result...*/
        super.onActivityResult(requestCode, resultCode, data);
    }

Activity B :

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ad_video);
    Bundle b = this.getIntent().getExtras();
    setResult(0);
    link = b.getString(LINK);
    videoView = (VideoView) findViewById(R.id.surface_view);
     videoView.setVideoPath(_link);
     videoView.requestFocus();
     videoView.start();
     videoView.setOnCompletionListener(new OnCompletionListener() {
        public void onCompletion(MediaPlayer mp)
        {
            setResult(0);
            ActivityB.this.finish();
        }
    });
}

Whatever i do, OnActivityResult is never called. Based on other questions

  1. i put the setResult with values > 0 (0,99)

  2. in android manifest there is no launchMode (I also tried to put launchMode to standard)

Thank you for any help

Upvotes: 2

Views: 1524

Answers (4)

Furqi
Furqi

Reputation: 2403

On the child activity, I used it on the child activity

getParent().startActivityForResult(intent, positive_request_code);

Upvotes: 0

Dany Y
Dany Y

Reputation: 7031

Ok i got it, The main issue was that i called the activtiy from within the tab host. I called it from the Activity that contains the tabs (the one that extends TabActivity) and it works.

So in brief, even though i'm using each tab as an activity,
the one that should call the startActivityForResult is the main activity that extends TabActivity.

Thank you all for your help

Upvotes: 0

Nirali
Nirali

Reputation: 13805

Try below code

Intent returnIntent = new Intent();
returnIntent.putExtra("ProfilePicPath", path);
setResult(RESULT_OK, returnIntent);
finish();

Upvotes: 0

Tony
Tony

Reputation: 2425

Try adding an intent to the result, this code works for me:

Intent in = new Intent(); 
setResult(101, in);
finish();

Upvotes: 1

Related Questions