Android Instant App: Showinstallprompt's Postinstallintent Does Nothing?
The app in the play store currently is configured to handle https://www.example.com/hello/in an intent filter to launch an activity and showInstallPrompt(...) is supposed to launch
Solution 1:
Please have a look at: https://github.com/googlesamples/android-instant-apps/tree/master/install-api and https://github.com/googlesamples/android-instant-apps/blob/master/install-api/features/install/src/main/java/com/instantappsamples/feature/install/InstallApiActivity.kt
- This sample app demonstrates how to use the Install API. The API triggers the Intent to install the app on device.
- The call also accepts the Intent, which is triggered after the installation is complete.
- The sample also shows the correct structure to implement
showInstallPrompt
method along withpostInstallIntent
.
Refer the sample code snippet:
privateval postInstallIntent = Intent(Intent.ACTION_VIEW,
Uri.parse("https://install-api.instantappsample.com/")).
addCategory(Intent.CATEGORY_BROWSABLE).
putExtras(Bundle().apply {
putString("The key to", "sending data via intent")
})
overridefunonCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_install)
val isInstantApp = InstantApps.isInstantApp(this)
findViewById<Button>(R.id.start_installation).apply {
isEnabled = isInstantApp
// Show the installation prompt only for an instant app.if (isInstantApp) {
setOnClickListener {
InstantApps.showInstallPrompt(this@InstallApiActivity,
postInstallIntent,
REQUEST_CODE,
REFERRER)
} }
} }
Post a Comment for "Android Instant App: Showinstallprompt's Postinstallintent Does Nothing?"