हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
AppCard होस्ट को कॉन्फ़िगर करना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
ऐप्लिकेशन कार्ड दिखाने वाले ऐप्लिकेशन से बातचीत करने के लिए, AppCardHost
का इस्तेमाल करें.
अनुमतियां
AppCardHost
का इस्तेमाल करने वाले किसी भी ऐप्लिकेशन के पास ये अनुमतियां होनी चाहिए:
android.permission.INTERACT_ACROSS_USERS_FULL
android.permission.QUERY_ALL_PACKAGES
- (सिर्फ़ एपीआई लेवल 34 और उसके बाद के वर्शन में)
android.car.permission.BIND_APP_CARD_PROVIDER
शुरू करें
होस्ट को शुरू करने के लिए, यह जानकारी दें:
- संदर्भ
updateRate
AppCard के अपडेट होने की दर, मिलीसेकंड में.
fastUpdateRate
EnforceFastUpdateRate
से टैग किए गए कॉम्पोनेंट के लिए, अपडेट रेट को मिलीसेकंड में दिखाना
responseExecutor
वह थ्रेड जिस पर आपको AppCard ऐप्लिकेशन से जवाब चाहिए.
डिज़ाइन
AppCardHost
के साथ इनमें से किसी एक तरीके से इंटरैक्ट किया जा सकता है:
या
AppCardListener
AppCardListener
कॉम्पोनेंट, AppCardHost
और AppCard ऐप्लिकेशन से कम्यूनिकेशन से जुड़े अपडेट पाने के लिए, AppCardHost
के साथ रजिस्टर करता है.
AppCardListener
के इंटरफ़ेस फ़ंक्शन के बारे में यहां बताया गया है.
fun onAppCardReceived(AppCardContainer)
यह फ़ंक्शन तब ट्रिगर होता है, जब किसी ऐप्लिकेशन से ऐप्लिकेशन कार्ड मिलता है. इसे AppCardContainer
के तौर पर भेजा जाता है, जो ऐप्लिकेशन कार्ड और appIdentifier
उपलब्ध कराता है. इससे, ऐप्लिकेशन कार्ड भेजने वाले ऐप्लिकेशन की पहचान की जा सकती है
fun onComponentReceived(AppCardComponentContainer)
यह फ़ंक्शन तब ट्रिगर होता है, जब किसी ऐप्लिकेशन से ऐप्लिकेशन कार्ड कॉम्पोनेंट मिलता है. इसे AppCardComponentContainer
के तौर पर भेजा जाता है. यह ऐप्लिकेशन कार्ड भेजने वाले ऐप्लिकेशन की पहचान करने के लिए, ऐप्लिकेशन कार्ड कॉम्पोनेंट Identifier
उपलब्ध कराता है. साथ ही, उस ऐप्लिकेशन कार्ड पर ले जाने के लिए स्ट्रिंग आईडी भी उपलब्ध कराता है जिससे कॉम्पोनेंट जुड़ा है.
fun onProviderRemoved(String, String?)
यह फ़ंक्शन तब ट्रिगर होता है, जब ऐप्लिकेशन कार्ड की सेवा देने वाली कंपनी को हटाया गया हो या बंद किया गया हो. दिए गए पैकेज के नाम और सेवा देने वाली कंपनी की अनुमति से जुड़े किसी भी ऐक्टिव ऐप्लिकेशन कार्ड को हटाने के लिए, इस तरीके का इस्तेमाल करें.
अगर अनुमति {@code null}
है, तो इसका मतलब है कि पूरा पैकेज हटा दिया गया है.
fun onProviderAdded(String, String?)
यह फ़ंक्शन तब ट्रिगर होता है, जब ऐप्लिकेशन कार्ड की सेवा देने वाली कोई कंपनी जोड़ी जाती है या फिर सेवा चालू की जाती है.
इस्तेमाल के उदाहरण. इस फ़ंक्शन को ट्रिगर के तौर पर इस्तेमाल करके, ऐप्लिकेशन कार्ड पिकर में मौजूद सभी ऐप्लिकेशन कार्ड रीफ़्रेश करें. अगर अनुमति {@code null}
है, तो पूरा पैकेज जोड़ा गया है.
fun onPackageCommunicationError(appIdentifier, Throwable)
यह फ़ंक्शन तब ट्रिगर होता है, जब AppCardHost
को AppCard की सेवा देने वाली कंपनी से संपर्क करने में कोई गड़बड़ी मिलती है.
इस्तेमाल के उदाहरण. इस तरीके का इस्तेमाल करके, उपयोगकर्ता को यह दिखाएं कि चुने गए AppCard में कोई गड़बड़ी हुई है.
API
fun refreshCompatibleapp()
जब भी होस्ट का इस्तेमाल करने वाली गतिविधि फिर से शुरू की जाती है, तब इस तरीके को कॉल किया जाना चाहिए. इससे होस्ट, उन ऐप्लिकेशन की सूची को रीफ़्रेश कर सकता है जो AppCards के साथ काम करते हैं.
fun destroy()
जब होस्ट का इस्तेमाल करने वाली कोई गतिविधि खत्म हो जाती है, तो इस तरीके को कॉल करें. इससे होस्ट, सभी कनेक्शन और इंटरनल सदस्यों को हटा सकता है.
fun registerListener(AppCardListener)
AppCardListener
को रजिस्टर करने के लिए इस्तेमाल किया जाता है.
fun unregisterListener(AppCardListener)
AppCardListener
को अनरजिस्टर करने के लिए इस्तेमाल किया जाता है.
fun getAllAppCards(AppCardContext)
रजिस्टर किए गए AppCardListener
को सिस्टम में दिए गए सभी ऐप्लिकेशन कार्ड के साथ देने के लिए, इस तरीके को कॉल करें. साथ ही, AppCardContext
का इस्तेमाल करके, सेवा देने वाली कंपनियों को अपने ऐप्लिकेशन कार्ड को स्ट्रक्चर करने के तरीके के बारे में अहम जानकारी दें.
fun requestAppCard(AppCardContext, appIdentifier, String)
रजिस्टर किए गए AppCardListener
को किसी खास ऐप्लिकेशन कार्ड की जानकारी देने के लिए, इस तरीके का इस्तेमाल करें. इसके लिए, AppCardContext
का इस्तेमाल करें, जो सेवा देने वाली कंपनियों को अपने ऐप्लिकेशन कार्ड को स्ट्रक्चर करने का तरीका बताता है.
fun notifyAppCardRemoved(appIdentifier, String)
ऐप्लिकेशन कार्ड की सेवा देने वाली कंपनी को सूचना दें कि उसका ऐप्लिकेशन कार्ड अब चालू नहीं है.
fun notifyAppCardInteraction(appIdentifier, String, String, String)
ऐप्लिकेशन कार्ड की सेवा देने वाली कंपनी को सूचना देना कि उसके ऐप्लिकेशन कार्ड से इंटरैक्ट किया गया है.
सिर्फ़ बटन क्लिक वाला इंटरैक्शन काम करता है. इसे AppCardMessageConstants.InteractionMessageConstants.MSG_INTERACTION_ON_CLICK
से दिखाया जाता है.
हमारा सुझाव है कि आप ऐप्लिकेशन कार्ड के लिए एक बटन बनाएं. इसमें onClick
लिसनर का इस्तेमाल करें, जो appIdentifier
, ऐप्लिकेशन कार्ड आईडी, कॉम्पोनेंट आईडी, और इंटरैक्शन आईडी के साथ इस फ़ंक्शन को कॉल करता है.
fun sendAppCardContextUpdate(AppCardContext, appIdentifier, String)
किसी खास ऐप्लिकेशन कार्ड के लिए AppCardContext
अपडेट भेजें. उदाहरण के लिए, पार्क मोड से ड्राइव मोड पर स्विच करते समय, इस तरीके का इस्तेमाल करके AppCardContext
अपडेट भेजें. इसमें हर ऐक्टिव ऐप्लिकेशन कार्ड के लिए, isInteractable
को false
पर सेट किया गया हो.
अक्सर पूछे जाने वाले सवाल
मुझे लागू करने के सैंपल कहां मिल सकते हैं?
होस्ट का सैंपल. यह टैब, सिस्टम में मौजूद सभी ऐप्लिकेशन कार्ड के साथ-साथ, जांच करने की सुविधाओं को दिखाता है.
DriverUI और Pano manager. Pano मैनेजर, पिकर के तौर पर काम करता है, जबकि DriverUI, प्रज़ेंटर के तौर पर काम करता है.
हर AppCardContentProvider
में कितने ऐप्लिकेशन कार्ड जोड़े जा सकते हैं?
AppCardContentProvider
में अनगिनत ऐप्लिकेशन कार्ड इस्तेमाल किए जा सकते हैं.
हालांकि, यह पक्का करें कि ऐप्लिकेशन कार्ड की संख्या, उपयोगकर्ता अनुभव को बेहतर बनाने के लिए तय की गई संख्या के हिसाब से हो.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-06-26 (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-06-26 (UTC) को अपडेट किया गया."],[],[],null,["# Configure an AppCard host\n\nUse `AppCardHost` to communicate with apps that show AppCards.\n\nPermissions\n-----------\n\nAny app that uses an `AppCardHost` must have the following permissions:\n\n- `android.permission.INTERACT_ACROSS_USERS_FULL`\n- `android.permission.QUERY_ALL_PACKAGES`\n- (In API level 34 and higher **only** ) `android.car.permission.BIND_APP_CARD_PROVIDER`\n\nInitialize\n----------\n\nTo initialize the host, provide:\n\n- Context\n- `updateRate` AppCard update rate in milliseconds.\n- `fastUpdateRate` Update rate in milliseconds for components tagged with `EnforceFastUpdateRate`\n- `responseExecutor` A thread on which you want to receive responses from AppCard apps.\n\nDesign\n------\n\nAn `AppCardHost` can be interacted with in one of two ways:\n\n- Register as an [`AppCardListener`](#appcardlistener)\n\nOR,\n\n- Interact with the [`AppCardHost` APIs](#api)\n\n### AppCardListener\n\nThe `AppCardListener` component registers itself with an `AppCardHost`\nto receive communication updates from the `AppCardHost` and AppCard apps.\nThe interface functions of an `AppCardListener` are detailed here.\n\n\u003cbr /\u003e\n\n`fun onAppCardReceived(AppCardContainer)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard has been received from an app. It's sent as an `AppCardContainer` which provides an AppCard and an `appIdentifier` to identify the app that sent the AppCard\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onComponentReceived(AppCardComponentContainer)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard component is received from an app. It's sent as an `AppCardComponentContainer`, which provides an AppCards component, `Identifier` to identify the app that sent the AppCard, and a string ID to point to the AppCard to which the component is related.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onProviderRemoved(String, String?)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard provider has been removed or disabled. Use this method to clean up any active AppCard related to the given package name and provider authority.\u003cbr /\u003e\n\nIf authority is `{@code null}`, then an entire package was removed.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onProviderAdded(String, String?)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard provider has been added or enabled.\u003cbr /\u003e\n\n**Sample usage.** Use this function as a trigger to refresh all available\nAppCards in an AppCard picker. If authority is `{@code null}`, then an entire\npackage was added.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onPackageCommunicationError(appIdentifier, Throwable)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when the `AppCardHost` encounters an error when communicating with an AppCard provider.\n\n\u003cbr /\u003e\n\n**Sample usage.** Use this method to show to the user that an AppCard they have\nselected has encountered an error.\n\n\u003cbr /\u003e\n\n### APIs\n\n\u003cbr /\u003e\n\n`fun refreshCompatibleapp()`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis method should be called whenever the activity that is using the host is resumed so that the host can refresh its list of apps that support AppCards.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun destroy()`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nCall this method when an activity that is using a host is destroyed so that the host can clean up all connections and internal members.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun registerListener(AppCardListener)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nUsed to register an `AppCardListener`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun unregisterListener(AppCardListener)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nUsed to unregister an `AppCardListener`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun getAllAppCards(AppCardContext)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nCall this method to supply a registered `AppCardListener` with all the AppCards provided in the system with a given `AppCardContext` that provides hints to the providers on how to structure their AppCard.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun requestAppCard(AppCardContext, appIdentifier, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nCall this method to supply a registered `AppCardListener` with a specific AppCard, given an `AppCardContext` that gives hints to the providers on how to structure their AppCard.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun notifyAppCardRemoved(appIdentifier, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nNotify an AppCard provider that its AppCard is no longer active.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun notifyAppCardInteraction(appIdentifier, String, String, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nNotify an AppCard provider that its AppCard has been interacted with. The only supported interaction is a button click, which is signified by a `AppCardMessageConstants.InteractionMessageConstants.MSG_INTERACTION_ON_CLICK`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nWe recommend creating a button for an AppCard with an `onClick` listener that calls this function with `appIdentifier`, AppCard ID, component ID, and interaction ID.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun sendAppCardContextUpdate(AppCardContext, appIdentifier, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSend an `AppCardContext` update for a specific AppCard. For example, when shifting from Park mode to Drive mode, use this method to send an `AppCardContext` update in which `isInteractable` is set to `false` for each active AppCard.\n\n\u003cbr /\u003e\n\nFAQ\n---\n\n1. Where can I find sample implementations?\n\n - [Sample host](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-host-lib/sample-host/). Shows all available AppCards in the system, along with\n testing capabilities.\n\n - DriverUI and [Pano manager](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/services/Car/car_product/distant_display/apps/CarDistantDisplayPanoManager/;l=1?q=CarDistantDisplayPanoManager&sq=&ss=android%2Fplatform%2Fsuperproject%2Fmain). Pano manager acts as the picker while\n DriverUI acts as the presenter.\n\n2. How many AppCards can each `AppCardContentProvider` support?\n\n An `AppCardContentProvider` can support an infinite number of AppCards.\n However, be sure to balance the number of AppCards with degraded performance\n versus a positive user experience."]]