# Print output for @column tags ?>
public
class
ServiceInfo
extends ComponentInfo
implements
Parcelable
java.lang.Object | |||
↳ | android.content.pm.PackageItemInfo | ||
↳ | android.content.pm.ComponentInfo | ||
↳ | android.content.pm.ServiceInfo |
Information you can retrieve about a particular application service. This corresponds to information collected from the AndroidManifest.xml's <service> tags.
Constants | |
---|---|
int |
FLAG_EXTERNAL_SERVICE
Bit in |
int |
FLAG_ISOLATED_PROCESS
Bit in |
int |
FLAG_SINGLE_USER
Bit in |
int |
FLAG_STOP_WITH_TASK
Bit in |
int |
FLAG_USE_APP_ZYGOTE
Bit in |
int |
FOREGROUND_SERVICE_TYPE_CAMERA
Constant corresponding to |
int |
FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
Constant corresponding to |
int |
FOREGROUND_SERVICE_TYPE_DATA_SYNC
Constant corresponding to |
int |
FOREGROUND_SERVICE_TYPE_LOCATION
Constant corresponding to |
int |
FOREGROUND_SERVICE_TYPE_MANIFEST
A special value indicates to use all types set in manifest file. |
int |
FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
Constant corresponding to |
int |
FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
Constant corresponding to |
int |
FOREGROUND_SERVICE_TYPE_MICROPHONE
Constant corresponding to |
int |
FOREGROUND_SERVICE_TYPE_NONE
The default foreground service type if not been set in manifest file. |
int |
FOREGROUND_SERVICE_TYPE_PHONE_CALL
Constant corresponding to |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<ServiceInfo> |
CREATOR
|
public
int |
flags
Options that have been set in the service declaration in the manifest. |
public
String |
permission
Optional name of a permission required to be able to access this Service. |
Inherited fields |
---|
Public constructors | |
---|---|
ServiceInfo()
|
|
ServiceInfo(ServiceInfo orig)
|
Public methods | |
---|---|
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
void
|
dump(Printer pw, String prefix)
|
int
|
getForegroundServiceType()
Return foreground service type specified in the manifest.. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int parcelableFlags)
|
Inherited methods | |
---|---|
public static final int FLAG_EXTERNAL_SERVICE
Bit in flags
: If set, the service can be bound and run in the
calling application's package, rather than the package in which it is
declared. Set from R.attr.externalService
attribute.
Constant Value: 4 (0x00000004)
public static final int FLAG_ISOLATED_PROCESS
Bit in flags
: If set, the service will run in its own
isolated process. Set from the
R.attr.isolatedProcess
attribute.
Constant Value: 2 (0x00000002)
public static final int FLAG_SINGLE_USER
Bit in flags
: If set, a single instance of the service will
run for all users on the device. Set from the
R.attr.singleUser
attribute.
Constant Value: 1073741824 (0x40000000)
public static final int FLAG_STOP_WITH_TASK
Bit in flags
: If set, the service will automatically be
stopped by the system if the user removes a task that is rooted
in one of the application's activities. Set from the
R.attr.stopWithTask
attribute.
Constant Value: 1 (0x00000001)
public static final int FLAG_USE_APP_ZYGOTE
Bit in flags
: If set, the service (which must be isolated)
will be spawned from an Application Zygote, instead of the regular Zygote.
The Application Zygote will pre-initialize the application's class loader,
and call a static callback into the application to allow it to perform
application-specific preloads (such as loading a shared library). Therefore,
spawning from the Application Zygote will typically reduce the service
launch time and reduce its memory usage. The downside of using this flag
is that you will have an additional process (the app zygote itself) that
is taking up memory. Whether actual memory usage is improved therefore
strongly depends on the number of isolated services that an application
starts, and how much memory those services save by preloading. Therefore,
it is recommended to measure memory usage under typical workloads to
determine whether it makes sense to use this flag.
Constant Value: 8 (0x00000008)
public static final int FOREGROUND_SERVICE_TYPE_CAMERA
Constant corresponding to camera
in
the R.attr.foregroundServiceType
attribute.
Use the camera device or record video.
For apps with targetSdkVersion
Build.VERSION_CODES.R
and
above, a foreground service will not be able to access the camera if this type is not
specified in the manifest and in
Service.startForeground(int, android.app.Notification, int)
.
Constant Value: 64 (0x00000040)
public static final int FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
Constant corresponding to connectedDevice
in
the R.attr.foregroundServiceType
attribute.
Auto, bluetooth, TV or other devices connection, monitoring and interaction.
Constant Value: 16 (0x00000010)
public static final int FOREGROUND_SERVICE_TYPE_DATA_SYNC
Constant corresponding to dataSync
in
the R.attr.foregroundServiceType
attribute.
Data(photo, file, account) upload/download, backup/restore, import/export, fetch,
transfer over network between device and cloud.
Constant Value: 1 (0x00000001)
public static final int FOREGROUND_SERVICE_TYPE_LOCATION
Constant corresponding to location
in
the R.attr.foregroundServiceType
attribute.
GPS, map, navigation location update.
Constant Value: 8 (0x00000008)
public static final int FOREGROUND_SERVICE_TYPE_MANIFEST
A special value indicates to use all types set in manifest file.
Constant Value: -1 (0xffffffff)
public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
Constant corresponding to mediaPlayback
in
the R.attr.foregroundServiceType
attribute.
Music, video, news or other media playback.
Constant Value: 2 (0x00000002)
public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
Constant corresponding to mediaProjection
in
the R.attr.foregroundServiceType
attribute.
Managing a media projection session, e.g for screen recording or taking screenshots.
Constant Value: 32 (0x00000020)
public static final int FOREGROUND_SERVICE_TYPE_MICROPHONE
Constant corresponding to microphone
in
the R.attr.foregroundServiceType
attribute.
Use the microphone device or record audio.
For apps with targetSdkVersion
Build.VERSION_CODES.R
and
above, a foreground service will not be able to access the microphone if this type is not
specified in the manifest and in
Service.startForeground(int, android.app.Notification, int)
.
Constant Value: 128 (0x00000080)
public static final int FOREGROUND_SERVICE_TYPE_NONE
The default foreground service type if not been set in manifest file.
Constant Value: 0 (0x00000000)
public static final int FOREGROUND_SERVICE_TYPE_PHONE_CALL
Constant corresponding to phoneCall
in
the R.attr.foregroundServiceType
attribute.
Ongoing phone call or video conference.
Constant Value: 4 (0x00000004)
public int flags
Options that have been set in the service declaration in the
manifest.
These include:
FLAG_STOP_WITH_TASK
, FLAG_ISOLATED_PROCESS
,
FLAG_SINGLE_USER
.
public String permission
Optional name of a permission required to be able to access this Service. From the "permission" attribute.
public ServiceInfo ()
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
public int getForegroundServiceType ()
Return foreground service type specified in the manifest..
Returns | |
---|---|
int |
foreground service type specified in the manifest.
Value is either 0 or a combination of FOREGROUND_SERVICE_TYPE_MANIFEST , FOREGROUND_SERVICE_TYPE_NONE , FOREGROUND_SERVICE_TYPE_DATA_SYNC , FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK , FOREGROUND_SERVICE_TYPE_PHONE_CALL , FOREGROUND_SERVICE_TYPE_LOCATION , FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE , FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION , FOREGROUND_SERVICE_TYPE_CAMERA , and FOREGROUND_SERVICE_TYPE_MICROPHONE |
public String toString ()
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns | |
---|---|
String |
a string representation of the object. |
public void writeToParcel (Parcel dest, int parcelableFlags)
Parameters | |
---|---|
dest |
Parcel |
parcelableFlags |
int |