Added in API level 1
Deprecated in API level 24

MockApplication


open class MockApplication : Application
kotlin.Any
   ↳ android.content.Context
   ↳ android.content.ContextWrapper
   ↳ android.app.Application
   ↳ android.test.mock.MockApplication

A mock android.app.Application class. All methods are non-functional and throw java.lang.UnsupportedOperationException. Override it as necessary to provide the operations that you need.

Summary

Inherited constants
Public constructors

Public methods
open Unit

Called by the system when the device configuration changes while your component is running.

open Unit

Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created.

open Unit

This method is for use in emulated process environments.

Inherited functions

Public constructors

MockApplication

Added in API level 1
MockApplication()

Public methods

onConfigurationChanged

Added in API level 1
open fun onConfigurationChanged(newConfig: Configuration): Unit

Deprecated: Deprecated in Java.

Called by the system when the device configuration changes while your component is running. Note that, unlike activities, other components are never restarted when a configuration changes: they must always deal with the results of the change, such as by re-retrieving resources.

At the time that this function has been called, your Resources object will have been updated to return resource values matching the new configuration.

For more information, read Handling Runtime Changes. If you override this method you must call through to the superclass implementation.

Parameters
newConfig Configuration: This value cannot be null.

onCreate

Added in API level 1
open fun onCreate(): Unit

Deprecated: Deprecated in Java.

Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created.

Implementations should be as quick as possible (for example using lazy initialization of state) since the time spent in this function directly impacts the performance of starting the first activity, service, or receiver in a process.

If you override this method, be sure to call super.onCreate().

Be aware that direct boot may also affect callback order on Android android.os.Build.VERSION_CODES#N and later devices. Until the user unlocks the device, only direct boot aware components are allowed to run. You should consider that all direct boot unaware components, including such android.content.ContentProvider, are disabled until user unlock happens, especially when component callback order matters.

.
If you override this method you must call through to the superclass implementation.

onTerminate

Added in API level 1
open fun onTerminate(): Unit

Deprecated: Deprecated in Java.

This method is for use in emulated process environments. It will never be called on a production Android device, where processes are removed by simply killing them; no user code (including this callback) is executed when doing so.
If you override this method you must call through to the superclass implementation.