Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 995 Bytes

get-the-application-context.md

File metadata and controls

31 lines (22 loc) · 995 Bytes

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.

{% tabs %} {% tab title="Android" %}

Android

getApplication

{% hint style="warning" %} MobileCore.getApplication may return null if the android.app.Application object was destroyed or if MobileCore.setApplicationwas not previously called. {% endhint %}

Syntax

public static Application getApplication()

Example

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

{% endtab %} {% endtabs %}