Thursday, May 17, 2018

Will a service resident in mobile phone system until I uninstall the App in Android?

Leave a Comment

I know that I can register a service by adding Code A in AndroidManifest.xml.

Will the service resident in mobile phone system until I uninstall the App?

Will the service may cost system resource when it stays in system?

Code A

<service android:name="bll.CleanupService"> </service> 

5 Answers

Answers 1

There are a lot of stuff available on internet related to service and it's usage, But still, I will try to answer as much as possible.

Service: It is android component where it runs on background and foreground of the system.

A foreground service performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. Foreground services must display a Notification. Foreground services continue running even when the user isn't interacting with the app.

Android - implementing startForeground for a service?

A background service performs an operation that is not noticeable to the user, It can be downloading any file. We can use this for long running operation.

Coming back to your question, will try to answer one by one.

Will the service resident in mobile phone system until I uninstall the App ?

Yes, It will reside on your phone until you not uninstall application. But it will not run infinite, As your job finished it will be stop.

Will the service cost may system resource when it stay in system?

It may cause, If you are not using it properly, If you are running background service we should know when to stop it, unless it will run continuously. It may also cause you memory related issue.

Answers 2

If you start the service and the task not complete till then the service will be there in the system. In case of low system resources, the system can kill your service. But you can add options like START_STICKY to start the service again automatically after the system is out of low resources. You can check this link for further understanding https://developer.android.com/reference/android/app/Service#ServiceLifecycle

Answers 3

A Service is an application component that can perform long-running operations in the background, and it doesn't provide a user interface. Another application component can start a service, and it continues to run in the background even if the user switches to another application.

There are two reasons that a service can be run by the system. If someone calls Context.startService() then the system will retrieve the service (creating it and calling its onCreate() method if needed) and then call its onStartCommand(Intent, int, int) method with the arguments supplied by the client. The service will at this point continue running until Context.stopService() or stopSelf() is called.

Will the service resident in mobile phone system until I uninstall the App ?

Yes. According to Service Lifecycle it can perform long-running operations in the background (i.e Unitil Install Application) until Context.stopService() or stopSelf() is called.

Will the service cost may system resource when it stay in system?

NOTE

Services should be used with caution.To allow running processes, Android sets a hard limit on the heap size alloted for each app. The exact heap size limit varies between devices based on how much RAM the device has available overall. If your app has reached the heap capacity and tries to allocate more memory, the system throws an OutOfMemoryError.

GOOD APPROACH

Developer’s responsibility to make sure that stopService() or stopSelf() is being called after work is done.

Answers 4

Will the service resident in mobile phone system until I uninstall the App ?

[ANS] : Yes,it will reside in mobile phone until you uninstall the app.

Will the service cost may system resource when it stay in system?

[ANS] : If you start the service and it does not stop (if you haven't called stopSelf()) when it's job is over,then it may cost system resources until you uninstall the app.

Answers 5

Will the service resident in mobile phone system until I uninstall the App?

  • Yes, the service does reside in mobile phone until the app is uninstalled.

Will the service cost may system resource when it stay in system?

  • There are different types of services, if the service is STICKY and the operation is not yet fully performed, the service will stay awake and will consume system resources.
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment