@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() |
Modifier and Type | Method and Description |
---|---|
void |
addWakeLock(android.os.PowerManager.WakeLock wl) |
void |
assertNoBroadcastListenersOfActionRegistered(android.content.ContextWrapper context,
java.lang.String action) |
boolean |
bindService(android.content.Intent intent,
android.content.ServiceConnection serviceConnection,
int i)
Deprecated.
Use
Context.bindService(Intent, ServiceConnection, int) instead. |
void |
callAttach(android.content.Context context)
Attaches an application to a base context.
|
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) . |
void |
clearWakeLocks() |
void |
declareActionUnbindable(java.lang.String action) |
android.appwidget.AppWidgetManager |
getAppWidgetManager() |
Scheduler |
getBackgroundThreadScheduler()
Return the background scheduler.
|
java.lang.Object |
getBluetoothAdapter() |
java.util.List<android.content.ServiceConnection> |
getBoundServiceConnections() |
Scheduler |
getForegroundThreadScheduler()
Return the foreground scheduler.
|
static ShadowApplication |
getInstance()
Deprecated.
Use
shadowOf( instead. |
ShadowAlertDialog |
getLatestAlertDialog()
Deprecated.
Use
ShadowAlertDialog.getLatestAlertDialog() instead. |
ShadowDialog |
getLatestDialog()
Deprecated.
Use
ShadowDialog.getLatestDialog() instead. |
android.widget.ListPopupWindow |
getLatestListPopupWindow() |
ShadowPopupMenu |
getLatestPopupMenu()
Deprecated.
Use
ShadowPopupMenu.getLatestPopupMenu() instead. |
android.widget.PopupWindow |
getLatestPopupWindow() |
android.os.PowerManager.WakeLock |
getLatestWakeLock() |
android.view.LayoutInflater |
getLayoutInflater() |
java.util.List<android.content.BroadcastReceiver> |
getReceiversForIntent(android.content.Intent intent)
Deprecated.
use PackageManager.queryBroadcastReceivers instead
|
java.util.List<ShadowApplication.Wrapper> |
getRegisteredReceivers() |
java.util.List<android.widget.Toast> |
getShownToasts() |
<T> T |
getSingleton(java.lang.Class<T> clazz,
Provider<T> provider) |
java.util.List<android.content.ServiceConnection> |
getUnboundServiceConnections() |
boolean |
hasReceiverForIntent(android.content.Intent intent)
Deprecated.
use PackageManager.queryBroadcastReceivers instead
|
android.content.Intent |
registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter)
Deprecated.
Use
Context.registerReceiver(BroadcastReceiver, IntentFilter) instead. |
android.content.Intent |
registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter,
java.lang.String broadcastPermission,
android.os.Handler scheduler)
Deprecated.
Use
Context.registerReceiver(BroadcastReceiver, IntentFilter, String,
Handler) instead. |
static void |
runBackgroundTasks()
Runs any background tasks previously queued by
AsyncTask.execute(Object[]) . |
void |
sendBroadcast(android.content.Intent intent)
Deprecated.
Use
Context.sendBroadcast(Intent) instead. |
void |
sendBroadcast(android.content.Intent intent,
java.lang.String receiverPermission)
Deprecated.
Use
Context.sendBroadcast(Intent, String) instead. |
void |
sendOrderedBroadcast(android.content.Intent intent,
java.lang.String receiverPermission)
Deprecated.
Use
Context.sendOrderedBroadcast(Intent, String) instead. |
void |
sendOrderedBroadcast(android.content.Intent intent,
java.lang.String receiverPermission,
android.content.BroadcastReceiver resultReceiver,
android.os.Handler scheduler,
int initialCode,
java.lang.String initialData,
android.os.Bundle initialExtras)
Deprecated.
Use
Context.sendOrderedBroadcast(android.content.Intent, java.lang.String) instead. |
void |
sendStickyBroadcast(android.content.Intent intent)
Deprecated.
Use
Context.sendStickyBroadcast(Intent) instead. |
void |
setComponentNameAndServiceForBindService(android.content.ComponentName name,
android.os.IBinder service) |
void |
setComponentNameAndServiceForBindServiceForIntent(android.content.Intent intent,
android.content.ComponentName name,
android.os.IBinder service) |
protected void |
setLatestAlertDialog(ShadowAlertDialog latestAlertDialog) |
protected void |
setLatestDialog(ShadowDialog latestDialog) |
protected void |
setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow) |
protected void |
setLatestPopupMenu(ShadowPopupMenu latestPopupMenu) |
protected void |
setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow) |
void |
setSystemService(java.lang.String key,
java.lang.Object service)
Deprecated.
Do not depend on this method to override services as it will be removed in a future update. The preferered method is use the shadow of the corresponding service.
|
void |
setUnbindServiceShouldThrowIllegalArgument(boolean flag) |
android.content.ComponentName |
startService(android.content.Intent intent)
Deprecated.
Use
Context.startService(Intent) instead. |
void |
stopService(android.content.Intent intent)
Deprecated.
Use
Context.stopService(Intent) instead. |
void |
unbindService(android.content.ServiceConnection serviceConnection)
Deprecated.
Use
Context.unbindService(ServiceConnection) instead. |
clearNextStartedActivities, clearStartedServices, denyPermissions, getBroadcastIntents, getNextStartedActivity, getNextStartedService, getNextStoppedService, 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(android.content.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 java.util.List<android.widget.Toast> getShownToasts()
public Scheduler getForegroundThreadScheduler()
Return the foreground scheduler.
public Scheduler getBackgroundThreadScheduler()
Return the background scheduler.
@Deprecated public android.content.Intent registerReceiver(android.content.BroadcastReceiver receiver, android.content.IntentFilter filter)
Context.registerReceiver(BroadcastReceiver, IntentFilter)
instead.@Deprecated public android.content.Intent registerReceiver(android.content.BroadcastReceiver receiver, android.content.IntentFilter filter, java.lang.String broadcastPermission, android.os.Handler scheduler)
Context.registerReceiver(BroadcastReceiver, IntentFilter, String,
Handler)
instead.@Deprecated public void sendBroadcast(android.content.Intent intent)
Context.sendBroadcast(Intent)
instead.@Deprecated public void sendBroadcast(android.content.Intent intent, java.lang.String receiverPermission)
Context.sendBroadcast(Intent, String)
instead.@Deprecated public void sendOrderedBroadcast(android.content.Intent intent, java.lang.String receiverPermission)
Context.sendOrderedBroadcast(Intent, String)
instead.@Deprecated public void sendStickyBroadcast(android.content.Intent intent)
Context.sendStickyBroadcast(Intent)
instead.@Deprecated public void sendOrderedBroadcast(android.content.Intent intent, java.lang.String receiverPermission, android.content.BroadcastReceiver resultReceiver, android.os.Handler scheduler, int initialCode, java.lang.String initialData, android.os.Bundle initialExtras)
Context.sendOrderedBroadcast(android.content.Intent, java.lang.String)
instead.@Deprecated public android.content.ComponentName startService(android.content.Intent intent)
Context.startService(Intent)
instead.@Deprecated public void stopService(android.content.Intent intent)
Context.stopService(Intent)
instead.@Deprecated public boolean bindService(android.content.Intent intent, android.content.ServiceConnection serviceConnection, int i)
Context.bindService(Intent, ServiceConnection, int)
instead.@Deprecated public void unbindService(android.content.ServiceConnection serviceConnection)
Context.unbindService(ServiceConnection)
instead.public void setComponentNameAndServiceForBindService(android.content.ComponentName name, android.os.IBinder service)
public void setComponentNameAndServiceForBindServiceForIntent(android.content.Intent intent, android.content.ComponentName name, android.os.IBinder service)
public void assertNoBroadcastListenersOfActionRegistered(android.content.ContextWrapper context, java.lang.String action)
public java.util.List<android.content.ServiceConnection> getBoundServiceConnections()
public void setUnbindServiceShouldThrowIllegalArgument(boolean flag)
public java.util.List<android.content.ServiceConnection> getUnboundServiceConnections()
@Deprecated public boolean hasReceiverForIntent(android.content.Intent intent)
@Deprecated public java.util.List<android.content.BroadcastReceiver> getReceiversForIntent(android.content.Intent intent)
public java.util.List<ShadowApplication.Wrapper> getRegisteredReceivers()
ShadowApplication.Wrapper
s for registered receiverspublic android.view.LayoutInflater getLayoutInflater()
Application
public android.appwidget.AppWidgetManager getAppWidgetManager()
Application
@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 java.lang.Object getBluetoothAdapter()
public void declareActionUnbindable(java.lang.String action)
public android.os.PowerManager.WakeLock getLatestWakeLock()
public void addWakeLock(android.os.PowerManager.WakeLock wl)
public void clearWakeLocks()
public <T> T getSingleton(java.lang.Class<T> clazz, Provider<T> provider)
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 android.widget.PopupWindow getLatestPopupWindow()
protected void setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow)
public android.widget.ListPopupWindow getLatestListPopupWindow()
protected void setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow)
@Deprecated public void setSystemService(java.lang.String key, java.lang.Object service)