WebAppManager
class WebAppManager
| kotlin.Any | |
| ↳ | android.content.pm.webapp.WebAppManager |
System service that manages the installation and querying of Web Apps.
This class acts as the entry point for managing Web Apps installed as Android apps.
To obtain an instance of this manager, use Context.getSystemService(Class):
<code>WebAppManager webAppManager = context.getSystemService(WebAppManager.class); </code>
Summary
| Public methods | |
|---|---|
| Unit |
install(request: WebAppInstallRequest, executor: Executor, callback: ObjIntConsumer<String!>)Requests the installation of a Web App. |
| Boolean |
Checks if the Web App service is available. |
| Unit |
query(request: WebAppQueryRequest, executor: Executor, callback: IntConsumer)Queries the status of a specific Web App package. |
Public methods
install
fun install(
request: WebAppInstallRequest,
executor: Executor,
callback: ObjIntConsumer<String!>
): Unit
Requests the installation of a Web App.
This operation is asynchronous. The request is processed by the system in the background, and the result is delivered via the provided callback.
| Parameters | |
|---|---|
request |
WebAppInstallRequest: The WebAppInstallRequest containing the app details (such as title and manifest URL). This value cannot be null. |
executor |
Executor: The Executor on which the callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
ObjIntConsumer<String!>: The callback to receive the installation result. The String is the package name of the installed web app. The int value is one of the result codes defined in WebAppInstallRequest. The String will be null if the result code is not WebAppInstallRequest.RESULT_SUCCESS. |
isAvailable
fun isAvailable(): Boolean
Checks if the Web App service is available.
| Return | |
|---|---|
Boolean |
true if the service is available, false otherwise. |
query
fun query(
request: WebAppQueryRequest,
executor: Executor,
callback: IntConsumer
): Unit
Queries the status of a specific Web App package.
This operation is asynchronous. The system checks if the package is installed by the Web App service and visible to the caller, delivering the result via the provided callback.
| Parameters | |
|---|---|
request |
WebAppQueryRequest: The WebAppQueryRequest containing the package name. This value cannot be null. |
executor |
Executor: The Executor on which the callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
IntConsumer: The callback to receive the query result. The int value is one of the result codes defined in WebAppQueryRequest. This value cannot be null. |