Java android.app Service fields, constructors, methods, implement or subclass

Example usage for Java android.app Service fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.app Service.

The text is from its open source code.

Subclass

android.app.Service has subclasses.
Click this link to see all its subclasses.

Field

intSTART_STICKY_COMPATIBILITY
Constant to return from #onStartCommand : compatibility version of #START_STICKY that does not guarantee that #onStartCommand will be called again after being killed.
intSTART_STICKY
Constant to return from #onStartCommand : if this service's process is killed while it is started (after returning from #onStartCommand ), then leave it in the started state but don't retain this delivered intent.
intSTART_NOT_STICKY
Constant to return from #onStartCommand : if this service's process is killed while it is started (after returning from #onStartCommand ), and there are no new start intents to deliver to it, then take the service out of the started state and don't recreate until a future explicit call to Context#startService Context.startService(Intent) .
intSTART_REDELIVER_INTENT
Constant to return from #onStartCommand : if this service's process is killed while it is started (after returning from #onStartCommand ), then it will be scheduled for a restart and the last delivered Intent re-delivered to it again via #onStartCommand .
intSTART_FLAG_REDELIVERY
This flag is set in #onStartCommand if the Intent is a re-delivery of a previously delivered intent, because the service had previously returned #START_REDELIVER_INTENT but had been killed before calling #stopSelf(int) for that Intent.
intSTART_FLAG_RETRY
This flag is set in #onStartCommand if the Intent is a retry because the original attempt never got to or returned from #onStartCommand(Intent,int,int) .

Method

ApplicationgetApplication()
Return the application that owns this service.
ContextgetApplicationContext()
ClassgetClass()
Returns the runtime class of this Object .
ResourcesgetResources()
SharedPreferencesgetSharedPreferences(String name, int mode)
StringgetString(@StringRes int resId)
Returns a localized string from the application's package's default string table.
ObjectgetSystemService(String name)
voidonCreate()
Called by the system when the service is first created.
voidsendBroadcast(Intent intent)
voidstartActivity(Intent intent)
voidstartForeground(int id, Notification notification)
If your service is started (running through Context#startService(Intent) ), then also make this service run in the foreground, supplying the ongoing notification to be shown to the user while in this state.
voidstopForeground(boolean removeNotification)
Synonym for #stopForeground(int) .
voidstopForeground(@StopForegroundFlags int flags)
Remove this service from foreground state, allowing it to be killed if more memory is needed.
voidstopSelf(int startId)
Old version of #stopSelfResult that doesn't return a result.