Most visited

Recently visited

Added in API level 1
Deprecated since API level 24

MockApplication

public class MockApplication
extends Application

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Application
         ↳ android.test.mock.MockApplication


This class was deprecated in API level 24.
Use a mocking framework like Mockito. New tests should be written using the Android Testing Support Library.

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

Summary

Inherited constants

From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

MockApplication()

Public methods

void onConfigurationChanged(Configuration newConfig)

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

void onCreate()

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

void onTerminate()

This method is for use in emulated process environments.

Inherited methods

From class android.app.Application
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Public constructors

MockApplication

Added in API level 1
MockApplication ()

Public methods

onConfigurationChanged

Added in API level 1
void onConfigurationChanged (Configuration newConfig)

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.

Parameters
newConfig Configuration: The new device configuration.

onCreate

Added in API level 1
void onCreate ()

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().

onTerminate

Added in API level 1
void onTerminate ()

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.

Hooray!