@Implements(value=android.app.Application.class) public class ShadowApplication extends ShadowContextWrapper
Application.| Modifier and Type | Class and Description |
|---|---|
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,
String action) |
void |
bind(org.robolectric.manifest.AndroidManifest appManifest,
org.robolectric.res.ResourceLoader resourceLoader)
Associates a
ResourceLoader with an Application instance. |
boolean |
bindService(android.content.Intent intent,
android.content.ServiceConnection serviceConnection,
int i) |
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). |
int |
checkPermission(String permission,
int pid,
int uid) |
void |
clearStartedServices()
Clears all
Intent started by startService(android.content.Intent) |
void |
clearWakeLocks() |
void |
declareActionUnbindable(String action) |
void |
denyPermissions(String... permissionNames) |
android.content.Context |
getApplicationContext() |
org.robolectric.manifest.AndroidManifest |
getAppManifest() |
android.appwidget.AppWidgetManager |
getAppWidgetManager()
Non-Android accessor.
|
org.robolectric.util.Scheduler |
getBackgroundThreadScheduler()
Return the background scheduler.
|
Object |
getBluetoothAdapter() |
List<android.content.ServiceConnection> |
getBoundServiceConnections() |
List<android.content.Intent> |
getBroadcastIntents() |
org.robolectric.util.Scheduler |
getForegroundThreadScheduler()
Return the foreground scheduler.
|
static ShadowApplication |
getInstance() |
ShadowAlertDialog |
getLatestAlertDialog() |
ShadowDialog |
getLatestDialog() |
android.widget.ListPopupWindow |
getLatestListPopupWindow() |
ShadowPopupMenu |
getLatestPopupMenu() |
android.widget.PopupWindow |
getLatestPopupWindow() |
android.os.PowerManager.WakeLock |
getLatestWakeLock() |
android.view.LayoutInflater |
getLayoutInflater()
Non-Android accessor.
|
android.content.Intent |
getNextStartedActivity()
Consumes the most recent
Intent started by startActivity(android.content.Intent) and returns it. |
android.content.Intent |
getNextStartedService()
Consumes the most recent
Intent started by startService(android.content.Intent) and returns it. |
android.content.Intent |
getNextStoppedService()
Consumes the
Intent requested to stop a service by stopService(android.content.Intent)
from the bottom of the stack of stop requests. |
List<android.content.BroadcastReceiver> |
getReceiversForIntent(android.content.Intent intent) |
List<ShadowApplication.Wrapper> |
getRegisteredReceivers()
Non-Android accessor.
|
List<android.widget.Toast> |
getShownToasts() |
<T> T |
getSingleton(Class<T> clazz,
Provider<T> provider) |
List<android.content.ServiceConnection> |
getUnboundServiceConnections() |
void |
grantPermissions(String... permissionNames) |
boolean |
hasReceiverForIntent(android.content.Intent intent) |
android.content.Intent |
peekNextStartedActivity()
Returns the most recent
Intent started by startActivity(android.content.Intent) without
consuming it. |
android.content.Intent |
peekNextStartedService()
Returns the most recent
Intent started by startService(android.content.Intent) without
consuming it. |
android.content.Intent |
registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter)
Always returns
null |
android.content.Intent |
registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter,
String broadcastPermission,
android.os.Handler scheduler) |
static void |
runBackgroundTasks()
Runs any background tasks previously queued by
AsyncTask.execute(Object[]). |
void |
sendBroadcast(android.content.Intent intent) |
void |
sendBroadcast(android.content.Intent intent,
String receiverPermission) |
void |
sendOrderedBroadcast(android.content.Intent intent,
String receiverPermission) |
void |
sendOrderedBroadcast(android.content.Intent intent,
String receiverPermission,
android.content.BroadcastReceiver resultReceiver,
android.os.Handler scheduler,
int initialCode,
String initialData,
android.os.Bundle initialExtras) |
void |
sendStickyBroadcast(android.content.Intent intent) |
void |
setComponentNameAndServiceForBindService(android.content.ComponentName name,
android.os.IBinder service) |
void |
setComponentNameAndServiceForBindServiceForIntent(android.content.Intent intent,
android.content.ComponentName name,
android.os.IBinder service) |
static void |
setDefaultDisplay(android.view.Display display) |
static void |
setDisplayMetricsDensity(float densityMultiplier) |
void |
setLatestAlertDialog(ShadowAlertDialog latestAlertDialog) |
void |
setLatestDialog(ShadowDialog latestDialog) |
void |
setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow) |
void |
setLatestPopupMenu(ShadowPopupMenu latestPopupMenu) |
void |
setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow) |
void |
setSystemService(String key,
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) |
void |
startActivity(android.content.Intent intent) |
void |
startActivity(android.content.Intent intent,
android.os.Bundle options) |
android.content.ComponentName |
startService(android.content.Intent intent) |
boolean |
stopService(android.content.Intent name) |
void |
unbindService(android.content.ServiceConnection serviceConnection) |
void |
unregisterReceiver(android.content.BroadcastReceiver broadcastReceiver) |
public static ShadowApplication getInstance()
public static void runBackgroundTasks()
AsyncTask.execute(Object[]).
Note: calling this method does not pause or un-pause the scheduler.
public static void setDisplayMetricsDensity(float densityMultiplier)
public static void setDefaultDisplay(android.view.Display display)
public void bind(org.robolectric.manifest.AndroidManifest appManifest,
org.robolectric.res.ResourceLoader resourceLoader)
ResourceLoader with an Application instance.appManifest - Android manifest.resourceLoader - Resource loader.public List<android.widget.Toast> getShownToasts()
public org.robolectric.util.Scheduler getForegroundThreadScheduler()
public org.robolectric.util.Scheduler getBackgroundThreadScheduler()
@Implementation public android.content.Context getApplicationContext()
@Implementation public void startActivity(android.content.Intent intent)
@Implementation
public void startActivity(android.content.Intent intent,
android.os.Bundle options)
@Implementation public android.content.ComponentName startService(android.content.Intent intent)
@Implementation public boolean stopService(android.content.Intent name)
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)
@Implementation
public boolean bindService(android.content.Intent intent,
android.content.ServiceConnection serviceConnection,
int i)
public List<android.content.ServiceConnection> getBoundServiceConnections()
public void setUnbindServiceShouldThrowIllegalArgument(boolean flag)
@Implementation public void unbindService(android.content.ServiceConnection serviceConnection)
public List<android.content.ServiceConnection> getUnboundServiceConnections()
public android.content.Intent getNextStartedActivity()
Intent started by startActivity(android.content.Intent) and returns it.getNextStartedActivity in class ShadowContextWrapperIntentpublic android.content.Intent peekNextStartedActivity()
Intent started by startActivity(android.content.Intent) without
consuming it.peekNextStartedActivity in class ShadowContextWrapperIntentpublic android.content.Intent getNextStartedService()
Intent started by startService(android.content.Intent) and returns it.getNextStartedService in class ShadowContextWrapperIntentpublic android.content.Intent peekNextStartedService()
Intent started by startService(android.content.Intent) without
consuming it.peekNextStartedService in class ShadowContextWrapperIntentpublic void clearStartedServices()
Intent started by startService(android.content.Intent)clearStartedServices in class ShadowContextWrapperpublic android.content.Intent getNextStoppedService()
Intent requested to stop a service by stopService(android.content.Intent)
from the bottom of the stack of stop requests.getNextStoppedService in class ShadowContextWrapperIntent for the next service requested to be stopped@Implementation public void sendBroadcast(android.content.Intent intent)
@Implementation
public void sendBroadcast(android.content.Intent intent,
String receiverPermission)
@Implementation
public void sendOrderedBroadcast(android.content.Intent intent,
String receiverPermission)
@Implementation
public void sendOrderedBroadcast(android.content.Intent intent,
String receiverPermission,
android.content.BroadcastReceiver resultReceiver,
android.os.Handler scheduler,
int initialCode,
String initialData,
android.os.Bundle initialExtras)
public List<android.content.Intent> getBroadcastIntents()
getBroadcastIntents in class ShadowContextWrapper@Implementation public void sendStickyBroadcast(android.content.Intent intent)
@Implementation
public android.content.Intent registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter)
nullnull@Implementation
public android.content.Intent registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter,
String broadcastPermission,
android.os.Handler scheduler)
@Implementation public void unregisterReceiver(android.content.BroadcastReceiver broadcastReceiver)
public void assertNoBroadcastListenersOfActionRegistered(android.content.ContextWrapper context,
String action)
public boolean hasReceiverForIntent(android.content.Intent intent)
public List<android.content.BroadcastReceiver> getReceiversForIntent(android.content.Intent intent)
public List<ShadowApplication.Wrapper> getRegisteredReceivers()
ShadowApplication.Wrappers for registered receiverspublic android.view.LayoutInflater getLayoutInflater()
Applicationpublic android.appwidget.AppWidgetManager getAppWidgetManager()
Applicationpublic ShadowAlertDialog getLatestAlertDialog()
public void setLatestAlertDialog(ShadowAlertDialog latestAlertDialog)
public ShadowDialog getLatestDialog()
public void setLatestDialog(ShadowDialog latestDialog)
public Object getBluetoothAdapter()
public void declareActionUnbindable(String action)
public android.os.PowerManager.WakeLock getLatestWakeLock()
public void addWakeLock(android.os.PowerManager.WakeLock wl)
public void clearWakeLocks()
public org.robolectric.manifest.AndroidManifest getAppManifest()
public void checkActivities(boolean checkActivities)
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.public ShadowPopupMenu getLatestPopupMenu()
public void setLatestPopupMenu(ShadowPopupMenu latestPopupMenu)
public android.widget.PopupWindow getLatestPopupWindow()
public void setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow)
public android.widget.ListPopupWindow getLatestListPopupWindow()
public void setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow)
@Implementation public int checkPermission(String permission, int pid, int uid)
public void grantPermissions(String... permissionNames)
grantPermissions in class ShadowContextWrapperpublic void denyPermissions(String... permissionNames)
denyPermissions in class ShadowContextWrapper@Deprecated public void setSystemService(String key, Object service)
Copyright © 2016. All rights reserved.