หน้านี้อธิบายวิธีที่นักพัฒนาแอปสามารถผสานรวม การติดตั้งในหน้า ซึ่งเป็นฟีเจอร์ทดสอบใหม่ สำหรับ Google Play ที่แสดงรายละเอียดผลิตภัณฑ์แอป Google Play ในอินเทอร์เฟซแบบครึ่งหน้า การติดตั้งในหน้าช่วยให้ผู้ใช้ได้รับประสบการณ์การใช้งานขั้นตอนการติดตั้งแอปที่ราบรื่นโดยไม่ต้องออกจากบริบทของแอป นักพัฒนาแอปสามารถผสานรวมและทดสอบฟีเจอร์การติดตั้งในหน้าสำหรับแอปที่เผยแพร่หรืออัปเดตใน Play
ข้อกำหนด
ข้อกำหนดเพื่อให้อินเทอร์เฟซแบบครึ่งหน้าปรากฏในแอป
- Google Play เวอร์ชันต่ำสุดต้องเป็น 40.4
- ระดับ API ของ Android ต้องเป็น 24 ขึ้นไป
เรียกใช้การติดตั้งในหน้าจากแอป
หากต้องการเรียกใช้การติดตั้งในหน้าแบบครึ่งหน้าจากแอป ให้สร้างอินสแตนซ์ของคลาส
Intent ซึ่งจะเปิด URL ของ Deep Link
ใช้โค้ดตัวอย่างต่อไปนี้ (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 ระบบจะทำ Deep Link ไปยัง Google Play |
ใช่ |
callerId |
ชื่อแพ็กเกจของแอปที่เรียก | ใช่ |
listing |
พารามิเตอร์ที่ไม่บังคับเพื่อระบุเป้าหมายสำหรับข้อมูลสินค้าใน Store ที่กำหนดเอง | ไม่ |
หากขั้นตอนการติดตั้งแอปไม่แสดงอินเทอร์เฟซแบบครึ่งหน้าสำหรับการติดตั้งในหน้าของ Google Play ระบบจะแสดงลิงก์โดยตรง (Deep Link) ไปยังข้อมูลสินค้าใน Google Play แทน