Menu

How does an app detect if a container was created using the Knox SDK?

There are two methods. You can:

  • call an API to do a one-time check if a container exists
  • set up an intent to detect in real-time when container creation completes (recommended)

Call API

To check if a Knox container was created and to get the container ID, call this API method:

KnoxContainerManager.getContainers()

This API was introduced with the Knox Premium SDK v2.0 and is now implemented in the Knox SDK. This API method can be called by the app which created the container.

Set up intent

With the Knox SDK, you can register for the intent. This intent is sent after you create a container by calling the API method:

KnoxContainerManager.createContainer()

The intent is generated regardless of whether container creation succeeds or fails.

The intent uses CONTAINER_CREATION_STATUS_CODE to return either a:

  • positive non-zero value - This is a container ID.
  • negative value - This is an error code, as described in the Javadocs for createContainer.

The intent also uses CONTAINER_CREATION_REQUEST_ID so that you can match a createContainer request with a result.