Number of Service's impact on application's efficiency

madhu

I've used 3 services in my android application.

1st Service: Listening to broadcast receivers.

2nd: In this service, I've used a Runnable, which runs every second to fetch the details of foreground application.

3rd: Uploading the data into server.

Now, I need to develop a library project which has above application's functionality.

Any services or receivers used in a library project will have to be declared in the Client application's manifest file. Here comes my questions:

  1. Can I use Threads instead of services so that I can skip the problems of declaring services definition into manifest files?? How ever, I'll have to use one service to implement broad cast listeners.

  2. Does number of services used in an application impacts on application's efficiency?? Because, Client's application might have one or two Services. If they wishes to include my library, then their number of services will be raised to 4 or 5. This will be a definite problem.

  3. If I use Threads whose life cycle is dependent on application's process, will I be having problems of getting it killed if there's no memory?? Services will get restarted if it gets killed but I do not know how to encounter this problem if I use threads.

An-droid

1- Threads and services are meant for diferent type of operations. For example a Foreground service would be to stream audio/video, a ThreadPool would be use for downloading lot of images and display them in imageviews (UniversalImageLoader, Volley) For single/simple operations you can use Asynctask, but when you need several threads you would prefer classic Threads and Handlers.

2- You can use several services in one application it won't affect the performance. Of course it depends on the quality of your code and the way the services interact with each others. For exemple in one of my application I use a service for downloads, 1 for connectivity, 1 for streaming live audio and audio files and 1 to manage these two. With that I use intent and broadcast receiver. No lags.

3- If application is killed, background services are killed too. It's up to you to terminate your threads cleanly in onDestroy() for example or with a broadcast receiver you can listen to the kill intent.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What's the impact of large number of file descriptors on Java applications

Application and service(s) deployment in Azure Service Fabric

python's **kwargs efficiency

Library's Methodcount impact on app

What's the difference between an Application, a Process, and a Service?

Service Fabric application's root directory

Do python's numeric types impact the low-level precision of a number?

How does the number of entries defined on the builder to a persisted ChronicleMap impact it's ability to scale?

Efficiency of STL's copy function

Scheme's block structure efficiency

What is the HBase RegexStringComparator's efficiency?

efficiency of javascript's concurrency model

Impact of Intrinsics and inlining on Lambda's performance?

What's the impact of eager_load=true?

order of subprocesses execution and it's impact on operations atomicity

Liferay setModifiedDate does not impact database's modifiedDate

What's the performance impact of calling an empty Action?

What's the impact of changing the length of a varchar in mysql?

efficiency of Python's itertools.product()

Efficiency measurments of Go's once Type

Calculating Kaufman's Efficiency Ratio in Python with Pandas?

Efficiency problem of customizing numpy's vectorized operation

What is the efficiency of python's list slicing?

What's the difference between application vs service frameworks?

How to provide RESTful web service(s) from WPF application?

How to choose a magic number for SQLite's PRAGMA application_id

Is it bad practice to have validation in the application service that checks if a DTO's id is valid or if one of the dto's properties is blank?

Script which returns a service name when you give it a service's default port number

Change number of executors impact