Summary: Nested Classes | Methods | Inherited Methods | [Expand All]
public interface

# ContainerHolder

implements Result Releasable

com.google.android.gms.tagmanager.ContainerHolder

## Class Overview

Holder for an active container. This container holder holds a container and also manages new versions of the container that may become available (through loading a saved version of the container from disk or from a network refresh).

This holder can be a successful `Result`, in which case `getContainer()` returns a non-null container, and `getStatus()` returns `Status.RESULT_SUCCESS`, or an unsuccessful `Result` in which case `getContainer` returns `null` and `getStatus` returns an unsuccessful status.

When a new version of a container becomes available, if a `ContainerHolder.ContainerAvailableListener` has been registered, it will be called. Any subsequent call to `getContainer` will make that container active, deactivate any previous container, and return the newly-active container. Only active containers fire tags; tags in non-active containers never fire.

If you ever want to stop container refreshing, call `release()`. Network activity to check for new versions will stop, and last returned container via `getContainer()` will no longer be usable.

## Summary

Nested Classes
interface | ContainerHolder.ContainerAvailableListener | Listener object that is called when a new container is available.

Public Methods
abstract Container | getContainer() Returns the last loaded container.
abstract void | refresh() Requests a refresh from the network.
abstract void | setContainerAvailableListener(ContainerHolder.ContainerAvailableListener listener) Sets a listener that will be called when a new container becomes available (whether in response to an explicit `refresh()` call, via the automatic refreshing that occurs, or as part of the initial loading of the container).

[Expand] Inherited Methods
From interface com.google.android.gms.common.api.Result
abstract Status | getStatus() Returns the status of this result.
From interface com.google.android.gms.common.api.Releasable
abstract void | release()

## Public Methods

#### public abstract Container getContainer ()

Returns the last loaded container. If that container is not already active, makes it active, and makes any previously loaded container inactive.

#### public abstract void refresh ()

Requests a refresh from the network. This call is asynchronous, so the refresh will not occur immediately.

In order to limit the frequency of network communication, the refresh method is throttled. After you call `refresh()`, you need to wait at least 15 minutes before calling this method again, otherwise, the subsequent call will be a no-op.

#### public abstract void setContainerAvailableListener (ContainerHolder.ContainerAvailableListener listener)

Sets a listener that will be called when a new container becomes available (whether in response to an explicit `refresh()` call, via the automatic refreshing that occurs, or as part of the initial loading of the container). That new container won't become active until `getContainer()` is called.

If there is a pending container available when the listener is added, it will be called immediately.

The listener will be called on the the looper of the handler with which the container was loaded, or the main looper if no such handler was provided.

##### Parameters

listener | the listener to register (or `null` to unregister)