Every time onActivityResult returning data as null in multi chain activity

Viewed 684

First of all, every answer of the related questions did not solve my problem, that's why I am creating a new question.

I have two apps. From the first app, I am calling intent for ACTION_VIEW with a URI with onActivityResult.

In the second app, I have set an intent filter for the same URI.

Now from Activity B, I am calling Activity C in App2 with onActivityResult.

From Activity C, I am calling Activity D with onActivityResult.

After some work in Activity D will set a result with some data in the bundle and set the result as OK.

Instead of getting this data in Activity C, I am getting intent in Activity B with data as null in the bundle.

And Activity B is sending the same response to Activity A of App1. Hence I am getting null data in App1 as well.

In Request,

App1 (Activity A) ---> App2 (Activity B) ---> Activity C ---> Activity D

In Response,

Expected : App1 (Activity A) <--- App2 (Activity B) <--- Activity C <--- Activity D

Actual : App1 (Activity A) <--- App2 (Activity B) <--- Activity D
with data as null.

Kindly help me to get data from Activity D of App2 to Activity A of App1.

CODE:

App1 Activity A:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(deepLinkUrl));
Intent chooser = Intent.createChooser(intent, title);
if (intent.resolveActivity(getPackageManager()) != null) {
    startActivityForResult(chooser, 1);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1) {
        if (data.getExtras() != null) {
            Log.e("onActivityResult", "responseIntent.getExtras() " + 
                     data.getExtras());
        }
    }
}

App2 Activity B:

Constants.deeplinkUri = getIntent().getData();
Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
intent.setData(Uri.parse(Constants.deeplinkUri));
startActivityForResult(intent, 100);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 100) {
        if (data.getExtras() != null) {
            Log.e("onActivityResult", "responseIntent.getExtras() " + 
                     data.getExtras());
        }
        setResult(Activity.RESULT_OK, data);
        finish();
    }
}

App2 Activity C:

Intent intent = new Intent(LoginActivity.this, PayActivity.class);
intent.setData(Uri.parse(Constants.deeplinkUri));
startActivityForResult(intent, 100);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 100) {
        if (data.getExtras() != null) {
            Log.e("onActivityResult", "responseIntent.getExtras() " + 
                     data.getExtras());
        }
        setResult(Activity.RESULT_OK, data);
        finish();
    }
}

App2 Activity D:

Intent returnIntent = new Intent();
returnIntent.putExtra("result", msg);
setResult(Activity.RESULT_OK, returnIntent);
finish();

Thanks in advance. Anyone?

1 Answers
Related