1

Is it possible to start a url-less instant app for result and pass the result back to the initial application? The example only shows start activity:

val uriBuilder = Uri.parse("https://play.google.com/store/apps/details")
        .buildUpon()
        .appendQueryParameter("id", "com.example.android")
        .appendQueryParameter("launch", "true")

// Optional parameters, such as referrer, are passed onto the launched
// instant app. You can retrieve these parameters using Activity.intent.data.
uriBuilder.appendQueryParameter("referrer", "exampleCampaignId")

val intent = Intent(Intent.ACTION_VIEW).apply {
    data = uriBuilder.build()
    setPackage("com.android.vending")
}
startActivity(intent)

And it seems to open the play store so how can it pass back the result to the initial activity?

Zachary Sweigart
  • 1,051
  • 9
  • 23
  • never tried, but have you tried it? https://stackoverflow.com/a/10407371/6668797 – TWL Sep 18 '19 at 17:37

1 Answers1

0

I developed a small sample app and found that it is not possible. The play store does not open the instant app with Activity.FLAG_ACTIVITY_FORWARD_RESULT so the result is not passed back. A work around is to put a broadcast receiver in the first app and then broadcast the result back from the instant app.

Zachary Sweigart
  • 1,051
  • 9
  • 23
  • the issue has been accepted by google https://issuetracker.google.com/issues/141497580 – Zachary Sweigart Sep 30 '19 at 19:19
  • Google has updated the issue to "won't fix" so you'll have to use the work around either with a broadcast receiver or with passing the package id of the calling app to the instant app as suggested by Google – Zachary Sweigart Jun 17 '20 at 19:50