27 Mart 2025'ten itibaren AOSP'yi derlemek ve AOSP'ye katkıda bulunmak için aosp-main
yerine android-latest-release
kullanmanızı öneririz. Daha fazla bilgi için AOSP'de yapılan değişiklikler başlıklı makaleyi inceleyin.
Uygulama kartı oluşturma
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
AppCard oluşturmak için uygulamanın manifestte AppCardContentProvider
öğesini genişleten bir sağlayıcı oluşturması gerekir. AppCardContentProvider
, AppCard'ların oluşturulmasını kolaylaştırmak için temel ayrıntıları soyutlar.
Manifest beyanı
AppCard oluşturmak için uygulamanın, manifestte AppCardContentProvider
uzantısını oluşturacak bir sağlayıcı oluşturması gerekir.
<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>
Paket başına yalnızca bir sağlayıcı tanımlanabilir ve bu özelliklere sahip olmalıdır:
android:exported="true"
android:enabled="true"
android:permission="@string/host_permission"
VEYA
@string/host_permission
, AppCard kitaplığında bulunur ve sistemin Android API sürümüne bağlı olarak bir izin tanımlar.
Dize kaynağının kullanılması yalnızca Gradle ile derleme yapılırken işe yarar. Soong'u kullanırken dize kaynağı değeriyle birlikte açık dizeyi uygun kaynak niteleyicisine göre belirtin.
(varsayılan) android:grantUriPermissions="false"
(varsayılan) android:forceUriPermissions="false"
Beklenmedik sonuçları önlemek için sağlayıcının android:authorities
içinde yalnızca tek bir yetkili tanımlaması gerekir.
İşleme dayalı bir intent filtresi bildirin,
com.android.car.appcard.APP_CARD_PROVIDER
Extend AppCardContentProvider
Bu bölümde override ve protected nihai yöntemleri açıklanmaktadır.
Geçersiz kılma yöntemleri
val authority: String
Bu yöntemi, android:authorities
manifest özelliğinde tanımlanan yetkiyi döndürmek için kullanın.
fun onCreate(): Boolean
Bu yöntem super.onCreate()
yöntemini çağırmalıdır. Bu yöntemi, AppCard istendiğinde ayarlanırsa gecikmeye neden olabilecek işlevleri ayarlamak için kullanın.
val appCardIds: List
Desteklenen AppCard kimliklerinin listesini döndürmek için bu yöntemi kullanın. Bu dize hataları günlüğe kaydetmek için kullanıldığından her kimliğin ayrıntılı olmasını öneririz.
fun onAppCardAdded(String, AppCardContext): AppCard
Bu yöntem, bir AppCard ilk kez gösterildiğinde çağrılır ve AppCard ile ilgili kimliği ve AppCard'ın nasıl görüntülendiğine dair ipuçları sağlayan AppCardContext
değerini sağlar.
Bu yöntemi, AppCards tarafından sağlayıcı olarak desteklenen tüm işlevleri ayarlamak için kullanın. Bu işlev çağrıldığında, verilen kimliğe karşılık gelen AppCard'ın etkin olduğu kabul edilir.
fun onAppCardRemoved(String)
Bu yöntem, AppCard'ın kalan örnekleri kullanıcıya gösterilmediğinde çağrılır ve tüm temizleme işlemlerini gerçekleştirir. Bu işlev çağrıldığında, verilen kimliğe karşılık gelen AppCard etkin değil olarak kabul edilir.
fun onAppCardContextChanged(String, AppCardContext)
Bu yöntem, sistem bir AppCard'ın nasıl görüntülendiğini güncellemek istediğinde çağrılır ve güncellenmiş bir AppCardContext
gönderir.
Korumalı nihai yöntemler
fun sendAppCardUpdate(AppCard)
Etkin bir AppCard için güncelleme sırasına almak üzere bu yöntemi çağırın.
fun sendAppCardComponentUpdate(String, Component)
Etkin bir AppCard'daki bileşen için güncelleme sıraya almak üzere bu yöntemi çağırın. Belirtilen bileşen EnforceFastUpdateRate
ile etiketlenmişse güncelleme hemen gönderilir.
SSS
Örnek uygulamalar nerede bulunur?
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-09-05 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 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/)"]]