I use the onActivityResult method in my ParentActivity , and I call ChildActivity from my ParentActivity in a Button click. In my ChildActivity , when I click the default back button, and when it goes to my ParentActivity , I don't get my requestCode , which I set in my ChildActivity in onStop() method, with:
setResult (2);
How can I return my requestCode from my ChildActivity to ParentActivity when I click the back button.
Please help me.
Thanks in advance.
Here is the ma code:
//Parent activity protected void onActivityResult(int requestCode, int resultCode, Intent data) { Toast.makeText(this,resultCode+"", Toast.LENGTH_LONG).show(); if(resultCode==2){ finish(); } } //Child activity protected void onStop() { setResult(2); super.onStop(); } protected void onPause() { setResult(2); super.onStop(); }
source share