Return a single value to Collect app from other app

I have a field which opens another app and returns some value.
The value is supposed to be filled
I debugged the app and ODK is receiving the value but not getting prefilled
Using the below snippets in 2nd app

val intent = Intent()
val code = "1234567890"
intent.putExtra("value", code)
setResult(Activity.RESULT_OK, intent)

And this is from xml of the form

 <input appearance="'Anot-building-form', form_name='Anot-building-form', question_id='building_polygon_id', question_name='Building Polygon')" ref="/data/information_of_block/building_polygon_id">
                <label>Building footprint polygon id</label>

getting this error

Attempting to return data to a widget or set of widgets not looking for data

Anything I am doing wrong here

PS: Does the params passed in with'Anot-building-form'....) will change the thing like it decide where to fill the received result?
It's not clearly mentioned in documents.

I don't spot any obvious problems. You may want to start by building the demo Counter app ( and making sure that works as intended for you.

Do you have any developer settings on your device like "Don't keep activities"? That could possibly interfere with the data return process.

No, those are provided to your application as extras and that's all.

Thank you for your response.

No there is no such setting like "Don't keep activities".

I debugged ODK Collect App and I found that the data was actually being returned back to ODK app. But as soon as the second app was launched it triggered onActivityResult with RESULT_CANCELED due to which it triggered waitingForDataRegistry.cancelWaitingForData();.

So the form was not able to fill the received data.

Also just to mention, when I finish the next app, onActivityResult gets triggered with RESULT_OK but since cancelWaitingForData() was called earlier received value could not be filled.

I am not sure why this behavor ocured.

PS: The second app is flutter app.

Great troubleshooting so far. It sounds like the issue has to do with the way your custom app is designed, maybe because of some Flutter default. I recommend seeing if you can find anything about Flutter apps immediately getting onActivityResult called. I don't have any other ideas beyond that but another community member might.