AppManager
public class AppManager implements Manager
TestAppManager |
The |
Manages the communication between the app and the host.
Summary
Public methods |
|
|---|---|
void |
@RequiresCarApi(value = 5)Dismisses the alert with the given |
void |
Requests the current template to be invalidated, which eventually triggers a call to |
void |
setSurfaceCallback(@Nullable SurfaceCallback surfaceCallback)Sets the |
void |
@RequiresCarApi(value = 5)Shows an alert on the car screen. |
void |
showToast(@NonNull CharSequence text, int duration)Shows a toast on the car screen. |
Public methods
dismissAlert
@RequiresCarApi(value = 5)
public void dismissAlert(int alertId)
Dismisses the alert with the given id.
This is a no-op if there is not an active alert with the given id
| Parameters | |
|---|---|
int alertId |
the |
| Throws | |
|---|---|
androidx.car.app.HostException |
if the remote call fails |
invalidate
public void invalidate()
Requests the current template to be invalidated, which eventually triggers a call to onGetTemplate to get the new template to display.
| Throws | |
|---|---|
androidx.car.app.HostException |
if the remote call fails |
setSurfaceCallback
public void setSurfaceCallback(@Nullable SurfaceCallback surfaceCallback)
Sets the SurfaceCallback to get changes and updates to the surface on which the app can draw custom content, or null to reset the listener.
This call requires the androidx.car.app.ACCESS_SURFACE permission to be declared.
The Surface can be used to draw custom content such as a navigation app's map.
Note that the listener relates to UI events and will be executed on the main thread using getMainLooper.
| Throws | |
|---|---|
java.lang.SecurityException |
if the app does not have the required permissions to access the surface |
androidx.car.app.HostException |
if the remote call fails |
showAlert
@RequiresCarApi(value = 5)
public void showAlert(@NonNull Alert alert)
Shows an alert on the car screen.
Alerts with the same id, in the scope of the application, are considered equal. Even if their content differ.
Posting an alert while another alert is displayed would dismiss the old alert and replace it with the new one.
Only navigation templates support alerts. Triggering an alert while showing a non-supported template results in the cancellation of the alert.
| Throws | |
|---|---|
androidx.car.app.HostException |
if the remote call fails |
java.lang.NullPointerException |
if |
showToast
public void showToast(@NonNull CharSequence text, int duration)
Shows a toast on the car screen.
| Parameters | |
|---|---|
@NonNull CharSequence text |
the text to show |
int duration |
how long to display the message |
| Throws | |
|---|---|
androidx.car.app.HostException |
if the remote call fails |
java.lang.NullPointerException |
if |