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 SummaryConstructors Constructor Description ShadowService()
- 
Method SummaryModifier and Type Method Description protected intgetForegroundServiceType()NotificationgetLastForegroundNotification()intgetLastForegroundNotificationId()booleangetNotificationShouldRemoved()intgetStopSelfId()Returns id passed tostopSelf(int)method.intgetStopSelfResultId()Returns id passed tostopSelfResult(int)method.booleanisForegroundStopped()booleanisLastForegroundNotificationAttached()Returns whether the last foreground notification is still "attached" to the service, meaning it will be removed when the service is destroyed.booleanisStoppedBySelf()protected voidonDestroy()protected voidstartForeground(int id, Notification notification)protected voidstartForeground(int id, Notification notification, int foregroundServiceType)protected voidstopForeground(boolean removeNotification)protected voidstopForeground(int flags)protected voidstopSelf()protected voidstopSelf(int id)protected booleanstopSelfResult(int id)Methods inherited from class org.robolectric.shadows.ShadowContextWrapperclearBroadcastIntents, clearNextStartedActivities, clearStartedServices, denyPermissions, denyPermissions, getAllStartedServices, getBroadcastIntents, getBroadcastIntentsForUser, getBroadcastOptions, getNextStartedActivity, getNextStartedActivityForResult, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, peekNextStartedActivityForResult, peekNextStartedService, removeSystemService
- 
Constructor Details- 
ShadowServicepublic ShadowService()
 
- 
- 
Method Details- 
onDestroy
- 
stopSelf
- 
stopSelf
- 
stopSelfResult
- 
startForeground
- 
startForeground@Implementation(minSdk=29) protected final void startForeground(int id, Notification notification, int foregroundServiceType)
- 
stopForegroundprotected void stopForeground(boolean removeNotification)
- 
getForegroundServiceType
- 
stopForeground
- 
getLastForegroundNotificationIdpublic int getLastForegroundNotificationId()
- 
getLastForegroundNotification
- 
isLastForegroundNotificationAttachedpublic boolean isLastForegroundNotificationAttached()Returns whether the last foreground notification is still "attached" to the service, meaning it will be removed when the service is destroyed.
- 
isStoppedBySelfpublic boolean isStoppedBySelf()- Returns:
- Is this service stopped by self.
 
- 
isForegroundStoppedpublic boolean isForegroundStopped()
- 
getNotificationShouldRemovedpublic boolean getNotificationShouldRemoved()
- 
getStopSelfIdpublic int getStopSelfId()Returns id passed tostopSelf(int)method. Make sure to check result ofisStoppedBySelf()first.
- 
getStopSelfResultIdpublic int getStopSelfResultId()Returns id passed tostopSelfResult(int)method. Make sure to check result ofisStoppedBySelf()first.
 
-