{"id":1513,"date":"2022-08-30T15:17:09","date_gmt":"2022-08-30T15:17:09","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/26\/returning-data-from-an-activity-to-another-activitys-fragment-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:09","modified_gmt":"2022-08-30T15:17:09","slug":"returning-data-from-an-activity-to-another-activitys-fragment-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/returning-data-from-an-activity-to-another-activitys-fragment-collection-of-common-programming-errors\/","title":{"rendered":"Returning data from an activity to another activity&#39;s fragment?-Collection of common programming errors"},"content":{"rendered":"<p>How can I pass data between an activity and a fragment belonging to another activity? I think that it should be something similar to passing data between activities through intents, but I&#8217;m not able to figure it out and couldn&#8217;t get any search result on it either.<\/p>\n<p>For example, I have two activities A and B.<\/p>\n<p>A has 3 fragments &#8211; &#8220;x&#8221;, &#8220;y&#8221; and &#8220;z&#8221;. Now I call B from &#8220;x&#8221; using startActivityForResult.<\/p>\n<p>When I try and come back to &#8220;x&#8221; from &#8220;B&#8221; via setResult, it actually takes me to onActivityResult of &#8220;A&#8221; and not the one in &#8220;x&#8230;&#8221;. Plus the requestCode and resultCode are some number (65536) and -1 respectively.<\/p>\n<p>Can anyone please help me with this?<\/p>\n<ol>\n<li>\n<p>Most likely your parent activity inplements <code>onActivityResult()<\/code> too, but in that method you forgot to call <code>super.onActivityResult(requestCode, resultCode, intent);<\/code> to pass unhandled request codes. Or you got request code clash and the same code is expeceted by parent activity and the fragment.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-26 18:02:49. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>How can I pass data between an activity and a fragment belonging to another activity? I think that it should be something similar to passing data between activities through intents, but I&#8217;m not able to figure it out and couldn&#8217;t get any search result on it either. For example, I have two activities A and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1513","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1513"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1513\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}