हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
ऐप्लिकेशन कार्ड बनाना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
AppCard बनाने के लिए, ऐप्लिकेशन को मेनिफ़ेस्ट में एक ऐसा प्रोवाइडर बनाना होगा जो AppCardContentProvider
को बढ़ाता है. AppCardContentProvider
, AppCard बनाने की प्रोसेस को आसान बनाने के लिए, बुनियादी जानकारी को अलग करता है.
मेनिफ़ेस्ट में एलान करना
AppCard बनाने के लिए, ऐप्लिकेशन को मेनिफ़ेस्ट में एक प्रोवाइडर बनाना होगा, ताकि AppCardContentProvider
को बढ़ाया जा सके.
<provider android:name=".SimpleAppCardContentProvider"
android:authorities="com.example.appcard.sample.media"
android:permission="@string/host_permission"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="com.android.car.appcard.APP_CARD_PROVIDER" />
</intent-filter>
</provider>
हर पैकेज के लिए, सिर्फ़ एक प्रोवाइडर को तय किया जा सकता है. साथ ही, इन प्रॉपर्टी का इस्तेमाल किया जा सकता है:
android:exported="true"
android:enabled="true"
android:permission="@string/host_permission"
या,
@string/host_permission
, AppCard लाइब्रेरी में मौजूद है. यह सिस्टम के Android API वर्शन के हिसाब से अनुमति तय करता है.
स्ट्रिंग रिसॉर्स का इस्तेमाल सिर्फ़ तब किया जा सकता है, जब Gradle का इस्तेमाल करके ऐप्लिकेशन बनाया जा रहा हो. Soong का इस्तेमाल करते समय, स्ट्रिंग रिसॉर्स की वैल्यू के साथ स्ट्रिंग को साफ़ तौर पर बताएं. इसके लिए, सही रिसॉर्स क्वालिफ़ायर का इस्तेमाल करें.
(default) android:grantUriPermissions="false"
(default) android:forceUriPermissions="false"
अनचाहे नतीजों से बचने के लिए, यह ज़रूरी है कि सेवा देने वाली कंपनी android:authorities
में सिर्फ़ एक अथॉरिटी तय करे.
कार्रवाई पर आधारित इंटेंट फ़िल्टर का एलान करें,
com.android.car.appcard.APP_CARD_PROVIDER
AppCardContentProvider को बढ़ाना
इस सेक्शन में, override और protected फ़ाइनल तरीकों के बारे में बताया गया है.
बदलाव करने के तरीके
val authority: String
इस तरीके का इस्तेमाल करके, android:authorities
मेनिफ़ेस्ट प्रॉपर्टी में तय की गई अथॉरिटी को वापस पाएं.
fun onCreate(): Boolean
इस तरीके को super.onCreate()
को कॉल करना होगा. इस तरीके का इस्तेमाल करके, ऐसी सुविधा सेट अप करें जिसकी वजह से AppCard का अनुरोध करने पर देरी हो सकती है.
val appCardIds: List
इस तरीके का इस्तेमाल करके, AppCard के उन आईडी की सूची पाएं जिनका इस्तेमाल किया जा सकता है. हमारा सुझाव है कि हर आईडी को वर्बोस बनाएं, क्योंकि इस स्ट्रिंग का इस्तेमाल गड़बड़ियों को लॉग करने के लिए किया जाता है.
fun onAppCardAdded(String, AppCardContext): AppCard
इस तरीके का इस्तेमाल तब किया जाता है, जब पहली बार AppCard दिखाया जाता है. यह AppCard और AppCardContext
से जुड़ा आईडी उपलब्ध कराता है. साथ ही, यह भी बताता है कि AppCard कैसे दिखाया जाता है.
इस तरीके का इस्तेमाल करके, AppCards की सुविधा देने वाले किसी भी ऐप्लिकेशन के लिए ज़रूरी फ़ंक्शन सेट अप करें. इस फ़ंक्शन को कॉल करने के बाद, दिए गए आईडी से जुड़ा AppCard चालू माना जाता है.
fun onAppCardRemoved(String)
इस तरीके का इस्तेमाल तब किया जाता है, जब उपयोगकर्ता को AppCard के कोई भी बचे हुए इंस्टेंस नहीं दिखाए जाते. साथ ही, यह सभी को मैनेज करता है. इस फ़ंक्शन को कॉल करने पर, दिए गए आईडी से जुड़ा AppCard बंद माना जाता है
fun onAppCardContextChanged(String, AppCardContext)
सिस्टम को जब यह अपडेट करना होता है कि AppCard कैसे दिखाया जाए, तब इस तरीके का इस्तेमाल किया जाता है. साथ ही, यह अपडेट किया गया AppCardContext
भेजता है.
सुरक्षित फ़ाइनल तरीके
fun sendAppCardUpdate(AppCard)
चालू AppCard के लिए अपडेट को लाइन में लगाने के लिए, इस तरीके का इस्तेमाल करें.
fun sendAppCardComponentUpdate(String, Component)
चालू AppCard में किसी कॉम्पोनेंट के लिए अपडेट को कतार में लगाने के लिए, इस तरीके का इस्तेमाल करें. अगर दिए गए कॉम्पोनेंट को EnforceFastUpdateRate
के साथ टैग किया गया है, तो
अपडेट तुरंत भेज दिया जाता है.
अक्सर पूछे जाने वाले सवाल
लागू करने के उदाहरण कहां हैं?
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-09-05 (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-09-05 (UTC) को अपडेट किया गया."],[],[],null,["To create an AppCard, an app must create a provider in the manifest that extends\n`AppCardContentProvider`. The `AppCardContentProvider` abstracts away underlying\ndetails to facilitate the creation of AppCards.\n\nManifest declaration\n\nTo create an AppCard, an app must create a provider in the manifest to extend\n`AppCardContentProvider`. \n\n \u003cprovider android:name=\".SimpleAppCardContentProvider\"\n android:authorities=\"com.example.appcard.sample.media\"\n android:permission=\"@string/host_permission\"\n android:exported=\"true\"\n android:enabled=\"true\"\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"com.android.car.appcard.APP_CARD_PROVIDER\" /\u003e\n \u003c/intent-filter\u003e\n \u003c/provider\u003e\n\n**Only one provider can be defined per package** and with these properties:\n\n- `android:exported=\"true\"`\n- `android:enabled=\"true\"`\n- `android:permission=\"@string/host_permission\"`\n\n OR,\n - `android:readPermission=\"@string/host_permission\"`\n\n AND,\n\n `android:writePermission=\"@string/host_permission\"`\n- `@string/host_permission` exists in the AppCard library and defines a\n permission depending on the Android API version of the system.\n\n Using the string resource works only when building with Gradle. When using\n Soong, specify the explicit string with the string resource value according\n to the appropriate resource qualifier.\n- (*default* ) `android:grantUriPermissions=\"false\"`\n\n- (*default* ) `android:forceUriPermissions=\"false\"`\n\n To avoid unexpected results, it's required that the provider define a single\n authority **only** in `android:authorities`.\n- Declare an action-based intent filter,\n `com.android.car.appcard.APP_CARD_PROVIDER`\n\nExtend AppCardContentProvider\n\nThis section describes **override** and **protected** final methods.\n\nOverride methods\n\n\u003cbr /\u003e\n\n`val authority: String` Use this method to return the authority defined in the `android:authorities` manifest property.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onCreate(): Boolean` This method must call `super.onCreate()`. Use this method to set up functionality that could potentially cause a delay if set up when an AppCard is requested.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`val appCardIds: List` Use this method to return the list of supported AppCard IDs. We recommend making each ID verbose since this string is used to log errors.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onAppCardAdded(String, AppCardContext): AppCard` This method is called when an AppCard is shown for the first time and provides the ID related to the AppCard and the `AppCardContext` that provide hints as to how the AppCard is displayed.\n\n\u003cbr /\u003e\n\nUse this method to set up any functionality required by the AppCards\nsupported as a provider. Once this function is called, the AppCard that\ncorresponds to the given ID is considered to be **active.**\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onAppCardRemoved(String)` This method is called when no remaining instances of the AppCard are shown to the user and handles all clean up. When this function is called, the AppCard that corresponds to the given ID is considered **inactive.**\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onAppCardContextChanged(String, AppCardContext)` This method is called when the system wants to update how an AppCard is displayed and sends an updated `AppCardContext`.\n\n\u003cbr /\u003e\n\nProtected final methods\n\n\u003cbr /\u003e\n\n`fun sendAppCardUpdate(AppCard)` Invoke this method to queue an update for an active AppCard.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun sendAppCardComponentUpdate(String, Component)` Invoke this method to queue an update for a component in an active AppCard. If the given component is tagged with `EnforceFastUpdateRate`, then the update is sent immediately.\n\n\u003cbr /\u003e\n\nFAQ\n\nWhere are the sample implementations?\n\n- [Calendar AppCard](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-lib/sample-calendar-app/)\n- [Media AppCard](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-lib/sample-media-app/)\n- [Weather AppCard](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-lib/sample-weather-app/)"]]