调用onActivityResult

调用onActivityResult

我知道有很多相同的问题,但是仍然没有调用OnActivityResult。

这是我的代码

活动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);
    }


活动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();
        }
    });
}


无论我做什么,都不会调用OnActivityResult
基于其他问题


我把setResult的值> 0(0,99)
在android manifest中没有launchMode(我也试图把
launchMode到标准)


感谢您的任何帮助

最佳答案

尝试向结果添加意图,此代码对我有用:

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

08-26 04:11