@ThreadSafe public final class ContextUtil extends Object
Context.| Modifier and Type | Method and Description |
|---|---|
static Context |
cleanContext(Context context)
Gets the Application Context of
context to prevent memory leaks
from Activity, Service, or similar contexts. |
public static Context cleanContext(Context context)
context to prevent memory leaks
from Activity, Service, or similar contexts.
This is typically used to check a Context parameter when entering a method that expects an Application context, because this will log whether the Context is correctly cleaned or not. This method is useful, because it tries to avoid breaking out of context during automated tests.
context - Context to clean. If this is a test context that
doesn't support Context.getApplicationContext(), then
context will be returned.context.