{"id":387,"date":"2016-06-20T21:06:34","date_gmt":"2016-06-20T20:06:34","guid":{"rendered":"https:\/\/mokrzycki.eu\/blog\/?p=387"},"modified":"2018-12-04T10:20:22","modified_gmt":"2018-12-04T09:20:22","slug":"return-result-from-fragment-to-fragment","status":"publish","type":"post","link":"https:\/\/mokrzycki.eu\/blog\/2016\/06\/20\/return-result-from-fragment-to-fragment\/","title":{"rendered":"Return result from fragment to fragment"},"content":{"rendered":"<pre>\/\/run dialog fragment in fragment\r\nFragment fragmentByTag = getFragmentManager().findFragmentByTag(DownloadDialogFragment.TAG);\r\nif (fragmentByTag == null) {\r\n    CustomDialog customDialog = new CustomDialog();\r\n\tcustomDialog.setTargetFragment(currentFragment, REQUEST_DOWNLOAD_FRAGMENT);\r\n    customDialog.show(getFragmentManager(), CustomDialog.TAG);\r\n}\r\n\r\n\/\/in dialog, init result to onActivityResult\r\ngetTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, optionalIntent);\r\ngetActivity().setResult(Activity.RESULT_OK);\r\n\r\n\/\/catch result in main fragment\r\n@Override\r\npublic void onActivityResult(int requestCode, int resultCode, Intent data) {\r\n    if (requestCode == REQUEST_DOWNLOAD_FRAGMENT &amp;&amp; resultCode == Activity.RESULT_OK) {\r\n        ..todo here\r\n    } else\r\n        super.onActivityResult(requestCode, resultCode, data);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/run dialog fragment in fragment Fragment fragmentByTag = getFragmentManager().findFragmentByTag(DownloadDialogFragment.TAG); if (fragmentByTag == null) { CustomDialog&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[500],"tags":[276,15,277,274,275],"_links":{"self":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/387"}],"collection":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/comments?post=387"}],"version-history":[{"count":4,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/387\/revisions"}],"predecessor-version":[{"id":706,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/387\/revisions\/706"}],"wp:attachment":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/media?parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/categories?post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/tags?post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}