ความตั้งใจที่จะเข้าร่วม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
"ตั้งใจที่จะเข้าร่วม" เป็นฟีเจอร์ใหม่ของเครื่องมือ Android Sender ซึ่งช่วยให้
แอปพลิเคชันผู้ส่งสำหรับ "เข้าร่วม" เซสชันการแคสต์ที่เริ่มต้นโดยแอปอื่นๆ หรือ
เสียง คุณตั้งค่าให้แอปผู้ส่งเปิดขึ้นด้วย Intent ที่สร้างโดยการแคสต์
SDK
ตัวอย่างเช่น เมื่อใช้เสียงเพื่อเริ่มเซสชันการแคสต์ Cast SDK จะสร้าง
การแจ้งเตือนที่ให้ผู้ใช้ควบคุมการเล่นในโทรศัพท์ Android ทุกรุ่น
บนเครือข่ายเดียวกัน เมื่อแตะการแจ้งเตือน Cast SDK จะสร้าง
ต้องการเปิดแอปของคุณเพื่อเข้าร่วมเซสชันการแคสต์
โปรดดู
ตัวอย่าง Cast Videos-Android
สำหรับการใช้งาน Intent to Join.
การใช้ผู้ส่งของ Android
หากต้องการเปิดใช้ฟีเจอร์นี้ ให้ทำตามขั้นตอนต่อไปนี้ในแอป
ตรวจสอบว่าแอปของคุณใช้ Android Sender SDK เวอร์ชันที่สูงกว่าอยู่แล้ว
11.4.0. ใน build.gradle
:
dependencies {
api 'com.google.android.gms:play-services-cast-framework:11.4.0'
}
เพิ่มตัวกรอง Intent ใหม่ในกิจกรรมที่คุณต้องการจัดการ Intent
การแจ้งเตือนรีโมตคอนโทรล (RCN) จะใช้ Intent เพื่อเปิดแอป
และเข้าร่วมเซสชันการแคสต์
เราขอแนะนำให้คุณใช้กิจกรรมที่
SessionManagerListener
โฮสต์อยู่ และ
onSessionStarted()
หรือ
onSessionStartFailed()
จะถูกเรียก
ตรวจสอบว่าตัวกรอง Intent ใหม่ไม่ซ้ำกันในระบบ Android ทั้งระบบ พ
ขอแนะนำให้คุณใช้แท็ก <data>
เพื่อดำเนินการดังกล่าว ดังนี้
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="your_app_scheme" android:host="your_app_host"
android:path="your_app_path"/>
</intent-filter>
ตัวอย่างของแท็ก <data>
<data android:scheme="https" android:host="example.com"
android:path="/cast/join"/>
ในกิจกรรมที่คุณกำหนดตัวกรอง Intent ใหม่ ให้เรียก
SessionManager.startSession(Intent)
ใน onResume()
:
override fun onResume() {
...
val intent = intent
// Intent with format: "<your_app_scheme>://<your_app_host><your_app_path>"
val intentToJoinUri = Uri.parse("https://example.com/cast/join")
if (intent.data != null && intent.data == intentToJoinUri) {
mCastContext.sessionManager.startSession(intent)
}
...
}
@Override
protected void onResume() {
...
Intent intent = getIntent();
// Intent with format: "<your_app_scheme>://<your_app_host><your_app_path>"
Uri intentToJoinUri = Uri.parse("https://example.com/cast/join");
if (intent.getData() != null && intent.getData().equals(intentToJoinUri)) {
mCastContext.getSessionManager().startSession(intent);
}
...
}
ตั้งค่า Google Cast Developer Console
หากต้องการใช้ฟีเจอร์ Intent การเข้าร่วม URI ของแอปและชื่อแพ็กเกจต้องเป็น
เพิ่มเข้ามาใน
Google Cast Developer Console

ผู้รับต้องอยู่ในรายชื่อและเผยแพร่ด้วยเพื่อให้ Intent ใช้งานได้
อย่างเหมาะสม
หากต้องการแสดงแอป ให้สลับตัวเลือกข้อมูลเป็น "ใช่" แล้วใส่ชื่อ
และกราฟิกขนาด 512x512 สำหรับแอปของคุณ

หลังจากตั้งค่าแล้ว คุณสามารถทดสอบการใช้งานด้วยการแจ้งเตือนรีโมตคอนโทรล
(RCN) ตามที่ระบุไว้ด้านล่างนี้
- ติดตั้งแอป Google Home ในโทรศัพท์ Android แล้วเชื่อมต่อ Wi-Fi ในอุปกรณ์
โทรศัพท์
- อุปกรณ์ที่พร้อมใช้งาน Cast จะตั้งค่าอุปกรณ์ Google Home ภายใต้เครือข่ายเดียวกัน
- เริ่มเซสชันการแคสต์ด้วยอุปกรณ์ Google Home โดยใช้
เครื่องมือสั่งการและควบคุม (CaC)
อุปกรณ์ Android หรือ iOS อีกเครื่องหนึ่ง หรือผ่านเสียง และตรวจสอบว่า Web Receiver
เปิดใช้งานแอปแล้ว
- รอสักครู่เพื่อรับ RCN บนโทรศัพท์ แล้วแตะการแจ้งเตือนเพื่อ
ทำให้เกิด Intent ควรเผยแพร่ Intent ไปยังแอปใดก็ตามที่
จะบันทึก Intent ด้วยข้อมูลที่จําเป็นเพื่อเข้าร่วมเซสชัน
SessionManagerListener.onSessionStarted(T, String)
จะปรากฏขึ้นและเข้าร่วมเซสชันนั้น
การยืนยัน
หากแอปเข้าร่วมเซสชันสำเร็จ
SessionManagerListener.onSessionStarted(T, String)
จะถูกเรียก หรือไม่เช่นนั้น
SessionManagerListener.onSessionStartFailed(T, int)
จะถูกเรียก สมมติว่าแอปของคุณจัดการกับเหตุการณ์เหล่านั้นอย่างถูกต้อง (สำหรับ
เช่น การเปิดตัวตัวควบคุมแบบขยายหรือมินิคอนโทรลเลอร์) คุณก็ไม่ต้อง
ดำเนินการเพิ่มเติม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eThe "Intent to Join" feature enables Android sender apps to join existing Cast sessions initiated by other apps or voice commands.\u003c/p\u003e\n"],["\u003cp\u003eTo enable this, add a specific intent filter to your activity, update your Android Sender SDK, and configure your app in the Google Cast Developer Console.\u003c/p\u003e\n"],["\u003cp\u003eThe Cast SDK creates an intent that launches your app and allows it to join the session when a user interacts with a Cast notification.\u003c/p\u003e\n"],["\u003cp\u003eVerify successful implementation by checking if \u003ccode\u003eSessionManagerListener.onSessionStarted\u003c/code\u003e or \u003ccode\u003eSessionManagerListener.onSessionStartFailed\u003c/code\u003e is called appropriately.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the CastVideos-Android sample for a working implementation of the Intent to Join feature.\u003c/p\u003e\n"]]],["The \"Intent to Join\" feature allows an Android sender app to join an existing Cast session. To enable it, ensure the app uses Android Sender SDK version 11.4.0 or greater, add a unique intent filter to an activity, and call `SessionManager.startSession(Intent)` in `onResume()`. The app URI and package name must be added to the Google Cast Developer Console, and the receiver must be listed. Tapping a Remote Control Notification triggers an intent, starting a session and calling `onSessionStarted()` if successful, otherwise `onSessionStartFailed()` is called.\n"],null,["# Intent to Join\n\n\"Intent to Join\" is a new feature of the Android Sender that allows a\nsender app to \"join\" a Cast session that has been initiated by other apps or\nvoice. You set up your sender app to be launched by an intent created by Cast\nSDK.\n\nFor example, when using voice to start a Cast session, Cast SDK creates a\nnotification that allows a user to control the playback on all Android phones\non the same network. When the notification is tapped, Cast SDK creates the\nintent to launch your app to join the Cast session.\n\nSee the\n[CastVideos-Android sample](https://github.com/googlecast/CastVideos-android)\nfor a working implementation of Intent to Join.\n\nUsing an Android Sender\n-----------------------\n\nTo enable this feature, perform the following steps in your app:\n\nMake sure your app is already using Android Sender SDK version greater than\n11.4.0. In `build.gradle`: \n\n dependencies {\n api 'com.google.android.gms:play-services-cast-framework:11.4.0'\n }\n\nAdd a new intent filter to an activity where you want to handle the intent. The\nintent will be used by Remote Control Notifications (RCN) to launch your app\nand join a Cast session.\nWe recommend you use the activity where\n[`SessionManagerListener`](/cast/docs/reference/android/com/google/android/gms/cast/framework/SessionManagerListener)\nis hosted, and either\n[`onSessionStarted()`](/cast/docs/reference/android/com/google/android/gms/cast/framework/SessionManagerListener#onSessionStarted(T,%20java.lang.String))\nor\n[`onSessionStartFailed()`](/cast/docs/reference/android/com/google/android/gms/cast/framework/SessionManagerListener#onSessionStartFailed(T,%20int))\nwill be called.\nMake sure the new intent filter is unique across the entire Android system. We\nrecommend you use the `\u003cdata\u003e` tag to do that, as follows: \n\n \u003cintent-filter\u003e\n \u003caction android:name=\"android.intent.action.VIEW\" /\u003e\n \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n \u003ccategory android:name=\"android.intent.category.BROWSABLE\" /\u003e\n \u003cdata android:scheme=\"your_app_scheme\" android:host=\"your_app_host\"\n android:path=\"your_app_path\"/\u003e\n \u003c/intent-filter\u003e\n\nExamples of `\u003cdata\u003e` tag: \n\n \u003cdata android:scheme=\"https\" android:host=\"example.com\"\n android:path=\"/cast/join\"/\u003e\n\nIn the activity where you define the new intent filter, call\n[`SessionManager.startSession(Intent)`](/cast/docs/reference/android/com/google/android/gms/cast/framework/SessionManager#startSession(android.content.Intent))\nin `onResume()`:\nKotlin \n\n```kotlin\noverride fun onResume() {\n ...\n val intent = intent\n // Intent with format: \"\u003cyour_app_scheme\u003e://\u003cyour_app_host\u003e\u003cyour_app_path\u003e\"\n val intentToJoinUri = Uri.parse(\"https://example.com/cast/join\")\n if (intent.data != null && intent.data == intentToJoinUri) {\n mCastContext.sessionManager.startSession(intent)\n }\n ...\n}\n```\nJava \n\n```java\n@Override\nprotected void onResume() {\n ...\n Intent intent = getIntent();\n // Intent with format: \"\u003cyour_app_scheme\u003e://\u003cyour_app_host\u003e\u003cyour_app_path\u003e\"\n Uri intentToJoinUri = Uri.parse(\"https://example.com/cast/join\");\n if (intent.getData() != null && intent.getData().equals(intentToJoinUri)) {\n mCastContext.getSessionManager().startSession(intent);\n }\n ...\n}\n```\n\nGoogle Cast Developer Console setup\n-----------------------------------\n\nTo utilize the Intent to Join feature, the app URI and package name must be\nadded in the\n[Google Cast Developer Console](https://cast.google.com/publish/#/overview).\n\nYour receiver must also be listed and published for Intent to Join to work\nproperly.\n\nTo list your app, toggle the listing option to \"YES\" and provide a title,\ndescription, and a 512x512 graphic for your app.\n\nAfter setup, you can test the implementation with Remote Control Notifications\n(RCN) as below:\n\n1. Install the Google Home App on an Android phone, and connect to Wi-Fi on the phone.\n2. The Cast-enabled device sets up the Google Home device under the same network.\n3. Initiate a Cast session with the Google Home device using the [Command and Control (CaC) Tool](https://casttool.appspot.com/cactool/), another Android or iOS device, or through voice and check if the Web Receiver app is launched.\n4. Wait for a few seconds to get RCN on the phone, and tap the notification to trigger the intent. The intent should be broadcasted to any app that registers the intent with the required data to join the session.\n\n[`SessionManagerListener.onSessionStarted(T, String)`](/cast/docs/reference/android/com/google/android/gms/cast/framework/SessionManagerListener#onSessionStarted(T,%20java.lang.String))\nwill be triggered and join the session.\n\nVerification\n------------\n\nIf your app successfully joins the session,\n[`SessionManagerListener.onSessionStarted(T, String)`](/cast/docs/reference/android/com/google/android/gms/cast/framework/SessionManagerListener#onSessionStarted(T,%20java.lang.String))\nis called. Otherwise,\n[`SessionManagerListener.onSessionStartFailed(T, int)`](/cast/docs/reference/android/com/google/android/gms/cast/framework/SessionManagerListener#onSessionStartFailed(T,%20int))\nis called. Assuming your app already handles those events properly (for\nexample, launching expanded controller or mini controller), you don't have to\ndo anything further."]]