Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Compare <a href="http://developer.android.com/reference/android/app/Activity.html#getApplication()" rel="noreferrer"><code>getApplication()</code></a> and <a href="http://developer.android.com/reference/android/content/Context.html#getApplicationContext()" rel="noreferrer"><code>getApplicationContext()</code></a>.</p> <p><code>getApplication</code> returns an <a href="http://developer.android.com/reference/android/app/Application.html" rel="noreferrer"><code>Application</code></a> object which will allow you to manage your global application state and respond to some device situations such as <a href="http://developer.android.com/reference/android/app/Application.html#onLowMemory()" rel="noreferrer"><code>onLowMemory()</code></a> and <a href="http://developer.android.com/reference/android/app/Application.html#onConfigurationChanged(android.content.res.Configuration)" rel="noreferrer"><code>onConfigurationChanged()</code></a>.</p> <p><code>getApplicationContext</code> returns the global application context - the difference from other contexts is that for example, an activity context may be destroyed (or otherwise made unavailable) by Android when your activity ends. The Application context remains available all the while your Application object exists (which is not tied to a specific <code>Activity</code>) so you can use this for things like <a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html" rel="noreferrer">Notifications</a> that require a context that will be available for longer periods and independent of transient UI objects.</p> <p>I guess it depends on what your code is doing whether these may or may not be the same - though in normal use, I'd expect them to be different.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload