I have two activities 1. MainActivity (launchMode is standard) 2. SecondActivity (launchMode is singleTask)
When I am calling SecondActivity from MainActivity, MainActivity's onActivityResult being called before onCreate of SecondActivity.
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
startActivityForResult(intent, 115);
Here is the onActivityResult() of MainActivity.
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//It is giving requestCode = 115, resultCode=0, without calling setResult anywhere.
}
Then it is coming to onCreate() of SecondActivity.
I have read that, this is a bug of android in the below link. onActivityResult() called prematurely
Is there any solution so far, I need launchMode to be singleTask for my SecondActivity.