Android onActivityResult is always 0

后端 未结 3 1580
清歌不尽
清歌不尽 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:06

    Your code is perfectly working........

    in u Activity B
    use
      setResult(0, mIntent);insted of setResult(RESULT_OK, mIntent);
    in your Activity A:
    use
    case 0: insted case RECIPE_CHOOSER: and 
    use System.out.println(b.getString("TEXT"));
    

    You will get output as

    Please work... pleeeeaasee

    0 讨论(0)
  • 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....

    0 讨论(0)
  • 2020-12-06 01:19

    Concerning your returned data.

    You do:

    Bundle b = getIntent().getExtras();
    

    but "getIntent()" returns the Intent that started THIS activity. If you want the returned data from the Activity you started for result, just take the data which is passed to

    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    
    0 讨论(0)
提交回复
热议问题