Android 12 Developer Preview is here! Try it out, and give us your feedback!

HostInfo

public final class HostInfo
extends Object

java.lang.Object
   ↳ androidx.car.app.HostInfo


Container class for information about the host the app is connected to.

Apps can use this information to determine how they will respond to the host. For example, a host which is not recognized could receive a message screen while an authorized host could receive full access to the app's capabilities.

The package name and uid can used to query the system package manager for a signature or to determine if the host has a system signature.

The host API level can be used to adjust the models exchanged with the host to those valid for the specific host version the app is connected to.

Summary

Public constructors

HostInfo(String packageName, int uid)

Constructs an instance of the HostInfo from the required package name, UID and API level.

Public methods

String getPackageName()

Returns the package name of the host.

int getUid()

Returns the UID of the host.

String toString()

Inherited methods

Public constructors

HostInfo

public HostInfo (String packageName, 
                int uid)

Constructs an instance of the HostInfo from the required package name, UID and API level.

Parameters
packageName String

uid int

Public methods

getPackageName

public String getPackageName ()

Returns the package name of the host.

Returns
String

getUid

public int getUid ()

Returns the UID of the host.

Returns
int

toString

public String toString ()

Returns
String