با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
با انتشار اندروید 5.0 اندروید تی وی که از Google Cast پشتیبانی می کند، عرضه می شود. این سند آنچه را که برای راهاندازی و آزمایش در Android TV هنگام توسعه برنامههای Cast باید انجام دهید، توضیح میدهد. برنامه Cast موجود شما در Android TV بدون هیچ تلاش اضافی اجرا می شود. اگر برای اولین بار است که یک برنامه Cast ایجاد میکنید، اسناد Google Cast را مرور کنید و قبل از توسعه و آزمایش با Android TV، برنامه Cast خود را برای اجرا در دستگاه Chromecast توسعه دهید.
راه اندازی برای توسعه
دستگاه Android TV خود را راه اندازی کنید:
دستگاه Android TV را به شبکه محلی وصل کنید.
وارد حساب گوگل خود شوید
از تنظیمات ، در ردیف دستگاه ، درباره را انتخاب کنید.
به پایین بروید و چندین بار روی Build کلیک کنید تا زمانی که یک گفتگو با پیام "You are now a developer" ظاهر شود.
در صورت اشکال زدایی USB:
کابل USB را نصب کنید، اما انتهای اصلی کابل USB را هنوز به رایانه خود وصل نکنید.
در ردیف Preferences ، Developer options را انتخاب کنید، USB debugging را انتخاب کنید و On را انتخاب کنید.
به صفحه اصلی برگردید. برای اعمال تنظیماتی که انتخاب کرده اید باید این کار را انجام دهید. تنظیمات باقی خواهند ماند مگر اینکه بازنشانی کارخانه ای انجام دهید.
سازگار کردن برنامه Cast خود با Android TV به کار اضافی کمی نیاز دارد. برای اطمینان از سازگاری برنامه شما با Android TV، توصیهها و مشکلات رایجی که باید از آنها اجتناب کنید در اینجا آمده است:
توجه داشته باشید که رشته user-agent شامل «Android» و «CrKey» است. برخی از سایتها ممکن است به یک سایت فقط تلفن همراه هدایت شوند زیرا برچسب "Android" را تشخیص میدهند. فرض نکنید که "Android" در رشته user-agent همیشه یک کاربر تلفن همراه را نشان می دهد.
پشته رسانه Android ممکن است از GZIP شفاف برای واکشی داده استفاده کند. مطمئن شوید که دادههای رسانه شما میتوانند به Accept-Encoding: gzip .
رویدادهای رسانه Android TV HTML5 ممکن است در زمانهای متفاوتی نسبت به Chromecast فعال شوند، این ممکن است مشکلاتی را نشان دهد که در Chromecast پنهان شدهاند.
هنگام بهروزرسانی رسانه، از رویدادهای مرتبط با رسانه که توسط عناصر <audio>/<video> اجرا میشوند، مانند timeupdate ، pause و waiting استفاده کنید. از استفاده از رویدادهای مرتبط با شبکه مانند progress ، suspend و stalled خودداری کنید، زیرا این رویدادها به پلتفرم وابسته هستند.
هنگام پیکربندی گواهیهای HTTPS سایت گیرنده وب خود، حتماً گواهیهای CA میانی را نیز لحاظ کنید. برای تأیید، به صفحه آزمایش Qualsys SSL مراجعه کنید: اگر مسیر تأیید اعتبار سایت شما دارای گواهینامه CA با عنوان «دانلود اضافی» باشد، ممکن است در پلتفرمهای مبتنی بر Android بارگیری نشود.
در حالی که Chromecast صفحه گیرنده وب را در صفحه گرافیکی 720p نمایش می دهد، سایر پلتفرم های Cast از جمله Android TV ممکن است صفحه را تا 1080p نمایش دهند. اطمینان حاصل کنید که صفحه گیرنده وب شما با رزولوشن های مختلف به خوبی مقیاس می شود.
استفاده از پل دیباگ اندروید
پلتفرم Android TV بر روی انواع مختلفی از دستگاه های الکترونیکی مصرفی مانند تلویزیون، ست تاپ باکس، کنسول های بازی و غیره ارائه می شود. هر کدام ممکن است به طور متفاوتی پیکربندی شوند. اگر در دسترسی به منابع سیستم Android TV از طریق رابط کاربری دستگاه مشکل دارید، میتوانید از Android Debug Bridge (ADB) برای دریافت شماره سریال دستگاه خود برای ثبت نام و همچنین اشکالزدایی برنامه خود استفاده کنید. برای اطلاعات بیشتر Android Debug Bridge را ببینید.
استفاده از ADB از طریق Wi-Fi
برای اتصال به دستگاه خود از طریق ADB با اتصال Wi-Fi:
در دستگاه Android TV خود، گزینههای برنامهنویس را همانطور که در راهاندازی برای توسعه توضیح داده شده است، فعال کنید.
مطمئن شوید که رایانه شما به همان شبکه دستگاه Android TV شما متصل است.
یک ترمینال باز کنید و موارد زیر را وارد کنید:
adb connect Android TV device IP address:4321
در رایانه خود، یک ترمینال را باز کنید و دستورات ADB را وارد کنید. با دستور زیر می توانید تأیید کنید که اتصال برقرار شده است و دستگاه Android TV در حال برقراری ارتباط در سراسر شبکه است:
adb logcat
استفاده از ADB با کابل USB
برای اتصال به دستگاه خود از طریق ADB با اتصال کابل USB:
همانطور که در تنظیمات برای توسعه توضیح داده شده است، دستگاه Android TV خود را برای توسعه تنظیم کنید.
انتهای اصلی کابل USB را به رایانه خود وصل کنید.
در Allow USB debugging؟ گفتگو، از این رایانه همیشه اجازه داده شود و OK را انتخاب کنید.
در رایانه خود، یک ترمینال را باز کنید و دستورات ADB را وارد کنید. با دستور زیر می توانید تأیید کنید که اتصال برقرار شده است و دستگاه Android TV در حال برقراری ارتباط در سراسر شبکه است:
adb logcat
استفاده از ADB از طریق TCP/IP
ADB بدون کابل USB، از طریق TCP/IP کار می کند، اما ابتدا باید آدرس IP دستگاه Android TV را دریافت کنید. دستگاههای دارای مشکل توسعهدهنده به طور خودکار به اتصالات درگاه ADB گوش میدهند و میتوانند بدون مقداردهی اولیه پورت متصل شوند. دستگاههای تلویزیون Android خردهفروشی استاندارد به طور خودکار به اتصالات ADB گوش نمیدهند. برای این دستگاه ها ابتدا باید با کابل USB به ADB متصل شده و پورت را مقدار دهی اولیه کنید.
همانطور که در تنظیمات برای توسعه توضیح داده شده است، دستگاه Android TV خود را برای توسعه تنظیم کنید.
در Android TV، در ردیف Device ، Network > Wi-Fi را انتخاب کنید و شبکه متصل را انتخاب کنید.
Status info را انتخاب کنید و آدرس IP را یادداشت کنید.
اگر دستگاه شما یک دستگاه Android TV استاندارد و خرده فروشی است، موارد زیر را انجام دهید:
مطمئن شوید رایانه شما به همان شبکه دستگاه Android TV متصل است.
در رایانه خود، در ترمینال، پورت TCP/IP را با وارد کردن موارد زیر مقداردهی اولیه کنید:
adb tcpip 5555
کابل USB را بردارید و موارد زیر را در ترمینال وارد کنید:
adb connect Android TV device IP address:5555
اگر دستگاه شما یک Android TV با مشکل توسعه دهنده است، موارد زیر را انجام دهید:
مطمئن شوید که رایانه شما به همان شبکه دستگاه Android TV شما متصل است.
یک ترمینال باز کنید و موارد زیر را وارد کنید:
adb connect Android TV device IP address:4321
در Android TV، در Allow USB debugging؟ گفتگو، از این رایانه همیشه اجازه داده شود و تأیید را انتخاب کنید. با دستور زیر می توانید تأیید کنید که اتصال برقرار شده است و دستگاه Android TV در حال برقراری ارتباط در سراسر شبکه است:
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eExisting Google Cast applications are compatible with Android TV without requiring modifications.\u003c/p\u003e\n"],["\u003cp\u003eBefore developing for Android TV, create a Cast application for Chromecast as a prerequisite.\u003c/p\u003e\n"],["\u003cp\u003eTo debug a Web Receiver on Android TV, connect through ADB and use Chrome DevTools (chrome://inspect).\u003c/p\u003e\n"],["\u003cp\u003eEnsure your Web Receiver handles various resolutions and potential user-agent string issues for compatibility.\u003c/p\u003e\n"],["\u003cp\u003eAndroid TV supports ADB debugging via USB, Wi-Fi, or TCP/IP for easier development and troubleshooting.\u003c/p\u003e\n"]]],[],null,["# Android TV with Google Cast\n\nWith the release of Android 5.0 comes Android TV, which supports Google Cast.\nThis document describes what you need to do to set up and test on Android TV\nwhen developing Cast applications. Your existing Cast application runs on\nAndroid TV with no additional effort. If you are developing a Cast application\nfor the first time, review the [Google Cast documentation](/cast/docs/developers)\nand develop your Cast application to run on a Chromecast device first before\ndeveloping and testing with Android TV.\n| **Note:** This document assumes that you have already developed an application that runs on a Chromecast device, as that is a mandatory first step toward having your Cast application running on Android TV.\n\nSetting up for development\n--------------------------\n\n1. Set up your Android TV device:\n 1. Connect the Android TV device to the local network.\n 2. Sign into your Google account.\n2. From the **Settings** , in the **Device** row, select **About**.\n3. Scroll down to and click on **Build** several times until a dialog appears with the message, \"You are now a developer.\"\n4. If USB debugging:\n 1. Install the USB cable, but don't connect the master end of the USB cable to your computer just yet.\n 2. In the **Preferences** row, select **Developer options** , select **USB debugging** , and select **On**.\n5. Navigate back to the home screen. You must do this to apply the settings you just selected. The settings will persist unless you perform a factory reset.\n6. Register your Android TV device on the [Google Cast SDK Developer Console](https://cast.google.com/publish), as described in [Device Registration](/cast/docs/registration#RegisterDevice).\n\nDebugging\n---------\n\nTo test and debug your Web Receiver application on your Android TV device, do the\nfollowing:\n\n1. Register your Android TV device and your application on the [Google Cast SDK Developer Console](https://cast.google.com/publish). See [Registration](/cast/docs/registration) for more information about registering devices and applications.\n2. Start your sender application and cast to the Android TV device.\n3. Connect to your Android TV device via ADB, as described in [Using Android Debug Bridge](#using_android_debug_bridge).\n4. On your development machine, open a Chrome browser window and navigate to **chrome://inspect** . **Note:** This is different than the [debugging option for a Chromecast device](/cast/docs/debugging#chrome_remote_debugger), where you navigate to your Web Receiver's IP address on port 9222.\n5. Click the **inspect** link to bring the Web Receiver into the debugger.\n6. In the Chrome Remote Debugger console, enable debug logging by entering the\n following:\n\n cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG);\n\nSee [Debugging](/cast/docs/debugging) for more information.\n\nGuidelines for Android TV compatibility\n---------------------------------------\n\nMaking your Cast application compatible with Android TV requires very little\nadditional work. Here are some recommendations and common pitfalls to avoid in\norder to ensure your application is compatible with Android TV:\n\n- Be aware that the user-agent string contains both \"Android\" and \"CrKey\"; some sites may redirect to a mobile-only site because they detect the \"Android\" label. Don't assume that \"Android\" in the user-agent string always indicates a mobile user.\n- Android's media stack may use transparent GZIP for fetching data. Make sure your media data can respond to `Accept-Encoding: gzip`.\n- Android TV HTML5 media events may be triggered in different timings than Chromecast, this may reveal issues that were hidden on Chromecast.\n- When updating the media, use media related events fired by `\u003caudio\u003e/\u003cvideo\u003e` elements, like `timeupdate`, `pause` and `waiting`. Avoid using networking related events like `progress`, `suspend` and `stalled`, as these tend to be platform dependent.\n- When configuring your Web Receiver site's HTTPS certificates, be sure to include intermediate CA certificates. See the [Qualsys SSL test page](https://www.ssllabs.com/ssltest/analyze.html) to verify: if the trusted certification path for your site includes a CA certificate labelled \"extra download\", then it may not load on Android-based platforms.\n- While Chromecast displays the Web Receiver page on a 720p graphics plane, other Cast platforms including Android TV may display the page up to 1080p. Ensure your Web Receiver page scales gracefully at different resolutions.\n\nUsing Android Debug Bridge\n--------------------------\n\nThe Android TV platform is featured on many kinds of consumer electronics\ndevices: televisions, set-top boxes, gaming consoles and so forth.\nEach may be configured differently. If you are having difficulty accessing the\nAndroid TV system resources through the device's user interface, you may\nuse the Android Debug Bridge (ADB) to obtain your device's serial number for\nregistration, as well as to debug your application. See [Android\nDebug Bridge](http://developer.android.com/tools/help/adb.html) for more\ninformation.\n\n### Using ADB over Wi-Fi\n\nTo connect to your device via ADB with a Wi-Fi connection:\n\n1. On your Android TV device, enabled developer options as described in [Setting up for development](#setting_up_for_development).\n2. Be sure your computer is connected to the same network as your Android TV device.\n3. Open a terminal and enter the following:\n\n ```\n adb connect Android TV device IP address:4321\n ```\n4. On your computer, open a terminal and enter ADB commands. You can verify the\n connection is established and that the Android TV device is communicating\n across the network with the following command:\n\n ```\n adb logcat\n ```\n\n### Using ADB with a USB cable\n\nTo connect to your device via ADB with a USB cable connection:\n\n1. Set up your Android TV device for development, as described in [Setting up for development](#setting_up_for_development).\n2. Connect the master end of the USB cable to your computer.\n3. In the **Allow USB debugging?** dialog, select **Always** allow from this computer, and select **OK**.\n4. On your computer, open a terminal and enter ADB commands. You can verify the\n connection is established and that the Android TV device is communicating\n across the network with the following command:\n\n ```\n adb logcat\n ```\n\n### Using ADB over TCP/IP\n\nADB works without a USB cable, over TCP/IP, but you must first get the Android\nTV device's IP address. Developer-issue devices listen for ADB port connections\nautomatically and can be connected without initializing the port. Standard\nretail Android TV devices do not listen for ADB connections automatically; for\nthese devices, you must first connect to ADB with a USB cable and initialize\nthe port.\n\n1. Set up your Android TV device for development, as described in [Setting up for development](#setting_up_for_development).\n2. On the Android TV, in the **Device** row, select **Network** \\\u003e **Wi-Fi**, and select the connected network.\n3. Select **Status info** and note the **IP address**.\n4. If your device is a standard, retail Android TV device, do the following:\n\n 1. Follow the steps under [Using ADB with a USB cable](#using_adb_with_a_usb_cable).\n 2. Be sure your computer is connected to the same network as the Android TV device.\n 3. On your computer, in a terminal, initialize the port for TCP/IP by\n entering the following:\n\n ```\n adb tcpip 5555\n ```\n 4. Remove the USB cable, and enter the following in the terminal:\n\n ```\n adb connect Android TV device IP address:5555\n ```\n5. If your device is a developer-issue Android TV, do the following:\n\n 1. Be sure your computer is connected to the same network as your Android TV device.\n 2. Open a terminal and enter the following:\n\n ```\n adb connect Android TV device IP address:4321\n ```\n6. On the Android TV, in the **Allow USB debugging?** dialog, select **Always\n allow from this computer** , and select **OK**. You can verify the connection\n is established and that the Android TV device is communicating across the\n network with the following command:\n\n ```\n adb logcat\n ```"]]