@Implements(value=android.app.Application.class) public class ShadowApplication extends ShadowContextWrapper
Modifier and Type | Class and Description |
---|---|
static class |
ShadowApplication.Wrapper |
Constructor and Description |
---|
ShadowApplication() |
clearNextStartedActivities, clearStartedServices, denyPermissions, denyPermissions, getBroadcastIntents, getNextStartedActivity, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, peekNextStartedService, removeSystemService
@Deprecated public static ShadowApplication getInstance()
shadowOf(androidx.test.core.app.ApplicationProvider#getApplicationContext
)
instead.public static void runBackgroundTasks()
Runs any background tasks previously queued by AsyncTask.execute(Object[])
.
Note: calling this method does not pause or un-pause the scheduler.
public void callAttach(Context context)
Attaches an application to a base context.
context
- The context with which to initialize the application, whose base context will be attached to the applicationpublic Scheduler getForegroundThreadScheduler()
Return the foreground scheduler.
public Scheduler getBackgroundThreadScheduler()
Return the background scheduler.
public void setComponentNameAndServiceForBindService(ComponentName name, IBinder service)
public void setComponentNameAndServiceForBindServiceForIntent(Intent intent, ComponentName name, IBinder service)
public void assertNoBroadcastListenersOfActionRegistered(ContextWrapper context, String action)
public List<ServiceConnection> getBoundServiceConnections()
public void setUnbindServiceShouldThrowIllegalArgument(boolean flag)
public List<ServiceConnection> getUnboundServiceConnections()
@Deprecated public boolean hasReceiverForIntent(Intent intent)
@Deprecated public List<BroadcastReceiver> getReceiversForIntent(Intent intent)
public List<ShadowApplication.Wrapper> getRegisteredReceivers()
ShadowApplication.Wrapper
s for registered receivers@Deprecated public AppWidgetManager getAppWidgetManager()
Context#getSystemService(Context.APPWIDGET_SERVICE)
intstead.@Deprecated public ShadowAlertDialog getLatestAlertDialog()
ShadowAlertDialog.getLatestAlertDialog()
instead.protected void setLatestAlertDialog(ShadowAlertDialog latestAlertDialog)
@Deprecated public ShadowDialog getLatestDialog()
ShadowDialog.getLatestDialog()
instead.protected void setLatestDialog(ShadowDialog latestDialog)
public Object getBluetoothAdapter()
public void declareActionUnbindable(String action)
public PowerManager.WakeLock getLatestWakeLock()
public void addWakeLock(PowerManager.WakeLock wl)
public void clearWakeLocks()
public void checkActivities(boolean checkActivities)
Set to true if you’d like Robolectric to strictly simulate the real Android behavior when calling Context.startActivity(android.content.Intent)
. Real Android throws a ActivityNotFoundException
if given an Intent
that is not known to the PackageManager
By default, this behavior is off (false).
checkActivities
- True to validate activities.@Deprecated public ShadowPopupMenu getLatestPopupMenu()
ShadowPopupMenu.getLatestPopupMenu()
instead.protected void setLatestPopupMenu(ShadowPopupMenu latestPopupMenu)
public PopupWindow getLatestPopupWindow()
protected void setLatestPopupWindow(PopupWindow latestPopupWindow)
public ListPopupWindow getLatestListPopupWindow()
protected void setLatestListPopupWindow(ListPopupWindow latestListPopupWindow)
@Deprecated public void setSystemService(String key, Object service)