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

Android

getApplication

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

Syntax

1
public static Application getApplication()
Copied!

Example

1
Application app = MobileCore.getApplication();
2
if (app != null) {
3
...
4
}
Copied!
Last modified 5mo ago
Export as PDF
Copy link