does a service take up any of the app's resources? - android

I have some things my app needs to do periodically
these things - if done while running the app itself, affect its performance - in terms, they make it VERY BAD
they have to do with downloading large jsons from the server and caching downloaded images
if i do all those things in a service, and the app is running while the service is running as well - will it affect any of the app's performance?
will the service take up any app memory allocated by dalvik ?

If you run the Service in a separate process, it will have less of an impact on the other parts of your app, but it will make communicating to the Service more difficult.
Are you saying that you know these operations affect performance? If so, what signs are you seeing? You may be running into problems because you're trying to run everything on the main thread; if so, using a background thread may solve the problem.

Related

Does Android have some functionality that kills all running processes and requires a reboot to fix?

I'm developing some Android devices that are constantly performing fairly intensive tasks.
I've noticed a strange issue happen (quite rarely, generally after 2-3 weeks of running continuously) where a device ceases to function, and all communications with it die. Since I don't have any access to these devices I can only assume that the OS has killed all running processes (there are several processes on it that communicate with several different backend servers, and they all disconnect simoultaneously)
I'm currently getting around this by implementing a firmware watchdog (by compiling it from source), but I am trying to figure out what is causing the devices to die in the first place.
Is there some android functionality that kills all processes and requires a reboot to fix? What can i do to avoid this happening? Are there any logs that I can view which show when this occurs?
Don't know what have done to the AOSP, but there do have some mechanisms to make a system reboot.
In init.rc, if a service is note as "critical" then if the service crashes more than 4 times, the system will reboot to the recovery mode.
In framework, if the a service belongs to core service and crashed, the system will restart the whole android, but not the kernel.
Temperature, there are two types temperature reboot schedule. One is CPU heat, but this has nothing to do with android, it is a CPU feature. Another, battery temperature, if a battery's heart is higher than expected, the healthd(a android demon on watching battery state) will notice the framework and the framework will reboot.
If the communication logic is written in a Android App, I suggest you to make this app as persist. This will make sure the app will stay in memory forever, and if the app is crashed, the system will restart this app. This may not solve you problem, but can resume the communication job.
I think it is not hard to figure out what's going on, usually the logcat contains the detail.
One of the explanations of your scenario is that the CPU overheats. In this case, not only the device will spontaneously shut down, it also cannot immediately reboot.
You may find temperature warnings in system log, but you can monitor this in your software, and throttle down CPU-intensive tasks to keep it from overheating.

Android: Clean Master App gives message "your application restarted 9 times in 5 minutes()"

I am getting a message like "your application restarted 9 times in 5 minutes()", when I tried to clean Junk Files using "Clean Master" application.
Please find the screenshot for this issue. I am not able to figure out why this message is coming. Any idea on this???
These apps may have once been useful but the Android has progressed far enough that they are now outdated, unnecessary and rather harmful.
On Windows, you want to keep as much RAM as possible as you can so that programs have enough room to operate. When RAM fills up, Windows is forced to start using hard drive space as virtual RAM and hard drives are much slower than physical RAM.
This is not true for Android.
Android’s operating system has its own native handler for assigning RAM to apps and making sure that all of it is being used in the most optimal way. In fact, Android purposely tries to keep apps loaded into RAM for better performance. RAM is fast, remember? On mobile devices, every bit of speed is critical for a good user experience, so keeping apps in RAM is actually a good thing.
Not only does Android handle RAM assignment, but it also keeps track of background apps so they don’t use up unnecessary processor resources. There’s no noticeable performance hit for leaving apps loaded in RAM.
App killers, memory boosters, performance enhancers, etc all claim wiping memory will speed up the phone. With current versions of Android, that's simply not true. It's actually the opposite. What will happen is the task killer app kills other apps which use resources to process. Then the OS restarts those, or other apps to fill the memory again, which takes even more resources. The task killer app kills again and the process repeats over and over. So in reality, those kinds of apps reduce performance and increase battery usage by restarting apps again and again. Remember, those dormant apps don't consume any additional battery or CPU in the first place.

Android Service CPU Consumption

Recently I have been helping my professor to develop an Android app, which is related to speech processing. Therefore this app involves lots of real-time computation including FFT and inverse-FFT. When the app runs in the foreground, it works okay. However when the app runs in Service, the app will become unresponsive.
Does anyone know the reason? Is it because when app is running in Service, its CPU consumption is limited? Can anyone give me some solutions? I am a newb in Android Programming...Thank you very much
Assign a CPU wakelock to the service. More information on wakelocks can be found at https://developer.android.com/training/scheduling/wakelock.html

How to run flex mobile application in background?

I need to run my android application (written in Flex) in the system background, so that periodically performs some defined task. Unfortunately I can not find any hints on the Internet:( I would also like to know how such an application to restore from the system background?
Please help if you know the solution.
Thank you.
Best,
Martin
I need to run my android application (written in Flex) in the system
background, so that periodically performs some defined task
Technically you should be able to minimized it on launch; however for performance issues non active applications are throttled. That means everything--including timers--will run slower than expected. So, 1 second on your timer will not necessarily equal 1 second in the real world when the application is inactive.
Unless it will be okay for the user to manually trigger your tasks; you should consider an alternate technology for the implementation. AIR is just not usually suitable for background applications.

How to keep service running after force-stop?

I've seen that if you kill some process, it restarts immediately and keep running. How this implemented? How to inform system that my service should not be killed and if that happened - restart it.
Android just does it. As an OS, Android is specifically designed to run with ram full at all times. So if you kill, or an app force closes it will, if their is room in ram for it be restarted by Android to fill the ram back up.
It does this because even the "fastest" phones are snails to even the most average of desktops and keeping as many programs that you use loaded in ram as possible enables it to simply "resume" the program instead of having to go through the slooooow, time wasting process of having to reload it back into ram and then running it from the beginning.
Android kernels have their own task manager. This means that it will be more efficient than any app-based task manager as it is run at the kernel level, and it should be left up to that task killer to decide when to free up memory or not free up memory. Let Android do what it was designed to do. Anything you do to try and force it to rerun a program or stop a program will, in the long run, slow it down more and possibly even cause stability issues.
However the short answer to your question is that there is no way to tell the "system" that your process should not be killed or to restart when it is closed. That is a choice made entirely by the kernel level task manager.
BTW, why would you want to? I ask this because I don't think you have thought this through very well. Remember, unlike IOS owners who are used to and expect total control over their device to be in the hands of Apple(for good or ill) Android owners expect, and will have control over their device. If you try to take that away from them, you will likely find most people uninstalling your service. And demanding their money back if you charge a fee for it.
I hope this has helped.
Not sure this is something that's good, but I've seen malware processes that have "buddy" processes that revive each other when one or more go down.
I hope whatever you're doing is ethical :-)

Categories

Resources