Google Play 内嵌安装(应用)
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了应用开发者如何集成内嵌式安装,这项 Google Play 新测试功能可在半页界面中显示 Google Play 应用商品详情。借助内嵌安装功能,用户无需离开应用上下文即可体验流畅的安装流程。应用开发者可以为通过 Play 分发或更新的应用集成和测试内嵌安装功能。
要求
如需在应用中显示半屏幕界面,请执行以下操作:
- Google Play 的最低版本必须为 40.4。
- Android API 级别必须为 23 或更高级别。
从应用调用内嵌式安装
如需从应用调用内嵌安装半页面,请创建 Intent
类的实例,该实例会打开深层链接网址。请参考以下示例代码(Kotlin 或 Java)。
Kotlin
val intent = Intent(Intent.ACTION_VIEW)
val referrer = "<Your referrer string>"
val id = "<Package name of the app that is to be installed>"
val callerId = "<Package name of your app>"
intent.setPackage("com.android.vending")
val deepLinkUrl = "https://play.google.com/d?id=$id&referrer=$referrer&listing=$csl_id"
intent.data = Uri.parse(deepLinkUrl)
intent.putExtra("overlay", true)
intent.putExtra("callerId", "$callerId")
val packageManager = context.getPackageManager()
if (intent.resolveActivity(packageManager) != null) {
startActivityForResult(intent, 0)
} else {
// Fallback to deep linking to full Play Store.
}
Java
Intent intent = new Intent(Intent.ACTION_VIEW);
String referrer = "<Your referrer string>";
String id = "<Package name of the app that is to be installed>";
String callerId = "<package name of your app>";
String csl_id = "<Custom store listing id>";
intent.setPackage("com.android.vending");
String deepLinkUrl = "https://play.google.com/d?id=" + id + "&referrer=" + referrer + "&listing=" + csl_id;
intent.setData(Uri.parse(deepLinkUrl));
intent.putExtra("overlay", true);
intent.putExtra("callerId", callerId);
PackageManager packageManager = context.getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
startActivityForResult(intent, 0);
} else {
// Fallback to deep linking to full Play Store.
}
内嵌安装 API 参数
字段 |
说明 |
必需 |
referrer |
可选的引荐来源跟踪字符串 |
否 |
id |
要安装的应用的
软件包名称 |
是 |
overlay |
如果请求内嵌半页面,请将其设为 true ;如果设为 false ,intent 会深层链接到 Google Play |
是 |
callerId |
调用方应用的
软件包名称 |
是 |
listing |
用于指定自定义商品详情的目标的选项参数 |
否 |
如果应用安装流程未显示 Google Play 内嵌安装半页面界面,则系统会改为显示指向 Google Play 商品详情的直接(深层链接)。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Google Play Inline Installs (Apps)\n\nThis page describes how app developers can integrate *inline install*, a new\ntest feature for Google Play that presents Google Play app product details in a\nhalf sheet interface. Inline install enables users to experience a seamless app\ninstall flow without leaving the context of the app. App developers can\nintegrate and test the inline install feature for Play distributed or updated\napps.\n\nRequirements\n------------\n\nFor the half sheet interface to appear in an app:\n\n- The minimum Google Play version must be **40.4**.\n- The Android API level must be **23 or higher**.\n\nInvoke inline installs from an app\n----------------------------------\n\nTo invoke inline install half sheet from an app, create an instance of the\n[`Intent`](/reference/android/content/Intent) class, which opens a deep link\nURL. Use the following sample code (Kotlin or Java) as a guideline. \n\n### Kotlin\n\n```kotlin\nval intent = Intent(Intent.ACTION_VIEW)\nval referrer = \"\u003cYour referrer string\u003e\"\nval id = \"\u003cPackage name of the app that is to be installed\u003e\"\nval callerId = \"\u003cPackage name of your app\u003e\"\nintent.setPackage(\"com.android.vending\")\nval deepLinkUrl = \"https://play.google.com/d?id=$id&referrer=$referrer&listing=$csl_id\"\nintent.data = Uri.parse(deepLinkUrl)\nintent.putExtra(\"overlay\", true)\nintent.putExtra(\"callerId\", \"$callerId\")\nval packageManager = context.getPackageManager()\nif (intent.resolveActivity(packageManager) != null) {\n startActivityForResult(intent, 0)\n} else {\n // Fallback to deep linking to full Play Store.\n}\n```\n\n### Java\n\n```java\nIntent intent = new Intent(Intent.ACTION_VIEW);\nString referrer = \"\u003cYour referrer string\u003e\";\nString id = \"\u003cPackage name of the app that is to be installed\u003e\";\nString callerId = \"\u003cpackage name of your app\u003e\";\nString csl_id = \"\u003cCustom store listing id\u003e\";\nintent.setPackage(\"com.android.vending\");\nString deepLinkUrl = \"https://play.google.com/d?id=\" + id + \"&referrer=\" + referrer + \"&listing=\" + csl_id;\nintent.setData(Uri.parse(deepLinkUrl));\nintent.putExtra(\"overlay\", true);\nintent.putExtra(\"callerId\", callerId);\nPackageManager packageManager = context.getPackageManager();\nif (intent.resolveActivity(packageManager) != null) {\n startActivityForResult(intent, 0);\n} else {\n // Fallback to deep linking to full Play Store.\n}\n```\n\nInline install API parameters\n-----------------------------\n\n| Field | Description | Required |\n|------------|---------------------------------------------------------------------------------------------------|----------|\n| `referrer` | An optional [referrer](/google/play/installreferrer) tracking string | No |\n| `id` | The [package name](https://support.google.com/admob/answer/9972781) of the app to be installed | Yes |\n| `overlay` | Set to `true` if inline half sheet is requested; if `false`, the intent deep links to Google Play | Yes |\n| `callerId` | The [package name](https://support.google.com/admob/answer/9972781) of the caller app | Yes |\n| `listing` | An optional parameter to specify the target for a custom store listing | No |\n\nIf the app install flow doesn't display the Google Play inline install half\nsheet interface, a direct (deep link) to the Google Play listing is shown\ninstead."]]