Package org.robolectric.shadows
Class ShadowService
- java.lang.Object
-
- org.robolectric.shadows.ShadowContextWrapper
-
- org.robolectric.shadows.ShadowService
-
- Direct Known Subclasses:
ShadowAccessibilityService
,ShadowInCallService
,ShadowIntentService
,ShadowJobService
,ShadowNotificationListenerService
,ShadowQuickAccessWalletService
,ShadowVoiceInteractionService
,ShadowVpnService
@Implements(android.app.Service.class) public class ShadowService extends ShadowContextWrapper
-
-
Constructor Summary
Constructors Constructor Description ShadowService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getForegroundServiceType()
Notification
getLastForegroundNotification()
int
getLastForegroundNotificationId()
boolean
getNotificationShouldRemoved()
int
getStopSelfId()
Returns id passed tostopSelf(int)
method.int
getStopSelfResultId()
Returns id passed tostopSelfResult(int)
method.boolean
isForegroundStopped()
boolean
isLastForegroundNotificationAttached()
Returns whether the last foreground notification is still "attached" to the service, meaning it will be removed when the service is destroyed.boolean
isStoppedBySelf()
protected void
onDestroy()
protected void
startForeground(int id, Notification notification)
protected void
startForeground(int id, Notification notification, int foregroundServiceType)
protected void
stopForeground(boolean removeNotification)
protected void
stopForeground(int flags)
protected void
stopSelf()
protected void
stopSelf(int id)
protected boolean
stopSelfResult(int id)
-
Methods inherited from class org.robolectric.shadows.ShadowContextWrapper
clearBroadcastIntents, clearNextStartedActivities, clearStartedServices, denyPermissions, denyPermissions, getAllStartedServices, getBroadcastIntents, getBroadcastIntentsForUser, getBroadcastOptions, getNextStartedActivity, getNextStartedActivityForResult, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, peekNextStartedActivityForResult, peekNextStartedService, removeSystemService
-
-
-
-
Method Detail
-
onDestroy
@Implementation protected void onDestroy()
-
stopSelf
@Implementation protected void stopSelf()
-
stopSelf
@Implementation protected void stopSelf(int id)
-
stopSelfResult
@Implementation protected boolean stopSelfResult(int id)
-
startForeground
@Implementation protected final void startForeground(int id, Notification notification)
-
startForeground
@Implementation(minSdk=29) protected final void startForeground(int id, Notification notification, int foregroundServiceType)
-
stopForeground
@Implementation protected void stopForeground(boolean removeNotification)
-
getForegroundServiceType
@Implementation(minSdk=29) protected final int getForegroundServiceType()
-
stopForeground
@Implementation(minSdk=24) protected void stopForeground(int flags)
-
getLastForegroundNotificationId
public int getLastForegroundNotificationId()
-
getLastForegroundNotification
public Notification getLastForegroundNotification()
-
isLastForegroundNotificationAttached
public boolean isLastForegroundNotificationAttached()
Returns whether the last foreground notification is still "attached" to the service, meaning it will be removed when the service is destroyed.
-
isStoppedBySelf
public boolean isStoppedBySelf()
- Returns:
- Is this service stopped by self.
-
isForegroundStopped
public boolean isForegroundStopped()
-
getNotificationShouldRemoved
public boolean getNotificationShouldRemoved()
-
getStopSelfId
public int getStopSelfId()
Returns id passed tostopSelf(int)
method. Make sure to check result ofisStoppedBySelf()
first.
-
getStopSelfResultId
public int getStopSelfResultId()
Returns id passed tostopSelfResult(int)
method. Make sure to check result ofisStoppedBySelf()
first.
-
-