Get the application context

In Android, you can retrieve the android.app.Application instance using the MobileCore.getApplication() API. The returned android.app.Application represents the base class, which maintains the global application state. For more information, see Mobile Core API reference.

Android

Android

getApplication

MobileCore.getApplication might return null if the android.app.Application object was destroyed or if MobileCore.setApplicationwas not previously called.

Syntax

public static Application getApplication()

Example

Application app = MobileCore.getApplication();
if (app != null) {
...
}