Android onActivityResult is always 0

我与影子孤独终老i 提交于 2019-11-27 22:06:13

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....

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)
Yasin JamesBond

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!