To create an AppCard, an app must create a provider in the manifest that extends
AppCardContentProvider
. The AppCardContentProvider
abstracts away underlying
details to facilitate the creation of AppCards.
Manifest declaration
To create an AppCard, an app must create a provider in the manifest to extend
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>
Only one provider can be defined per package and with these properties:
android:exported="true"
android:enabled="true"
android:permission="@string/host_permission"
OR,
android:readPermission="@string/host_permission"
AND,
android:writePermission="@string/host_permission"
@string/host_permission
exists in the AppCard library and defines a permission depending on the Android API version of the system.Using the string resource works only when building with Gradle. When using Soong, specify the explicit string with the string resource value according to the appropriate resource qualifier.
(default)
android:grantUriPermissions="false"
(default)
android:forceUriPermissions="false"
To avoid unexpected results, it's required that the provider define a single authority only in
android:authorities
.Declare an action-based intent filter,
com.android.car.appcard.APP_CARD_PROVIDER
Extend AppCardContentProvider
This section describes override and protected final methods.
Override methods
val authority: String
android:authorities
manifest property.fun onCreate(): Boolean
super.onCreate()
. Use this
method to set up functionality that could potentially cause a delay if set
up when an AppCard is requested.val appCardIds: List
fun onAppCardAdded(String, AppCardContext): AppCard
AppCardContext
that provide
hints as to how the AppCard is displayed.
Use this method to set up any functionality required by the AppCards supported as a provider. Once this function is called, the AppCard that corresponds to the given ID is considered to be active.
fun onAppCardRemoved(String)
fun onAppCardContextChanged(String, AppCardContext)
AppCardContext
.Protected final methods
fun sendAppCardUpdate(AppCard)
fun sendAppCardComponentUpdate(String, Component)
EnforceFastUpdateRate
, then
the update is sent immediately.FAQ
Where are the sample implementations?