Android onActivityResult is always 0

后端 未结 3 1592
清歌不尽
清歌不尽 2020-12-06 00:42

This has been killing me for two days now. I have a main Activity A which calls a second Activity B. Activity B simply presents the user with a listview. When I press an ite

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 01:07

    In your list activity, onItemClickListener try the following replacing the setResult lines with:

    if (getParent() == null) {
        setResult(Activity.RESULT_OK, data);
    }
    else {
        getParent().setResult(Activity.RESULT_OK, data);
    }
    

    I'm wondering whether there is a parent activity which is what you need to bind the data to and set the result on....

提交回复
热议问题