I am having using onActivityResult method in my ParentActivity and i call a 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 am not getting my requestCode that i set in my ChildActivity in onStop() method by:
setResult(2);
How can I return my requestCode from my ChildActivity to ParentActivity when I click back button.
Here is my 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();
}
You can use this code in your child activity
This piece of code will return result ok code from your child activity to parent activity
Now in your parent activity in
Let me know if this helps you