[Q] How to demo automatic killing of a process - Android Software Development

I want to observe an app's process being killed automatically (when the app's activity is stopped and other processes need the memory). I'm keeping my eye on Android Studio's Devices pane while I launch other processes, but this doesn't seem to kill my dormant activity. Is there a way to insure that this happens (and is observable)? (I know, . . . Why would I ever want to do this? It's because I'm teaching Android and I want to illustrate this concept.)

Related

[Help] Apps keep starting after killed

I am having a SGS asia version with latest firmware.
i have rooted it with su access and using process manager to kill those unwanted application (google map, double clock, and others....) running from behind.
but after certain time (range from 1 hour to 2 hours), those unwanted application will load back and take up the memory again. I have to manually killed them again and the remaining RAM is reduced in the process.
Is anyone facing similar problem ?
anyone know how to permanently stop this ? is there any program in the Samsung that keep summoning those application ?
Thank you.
Ya, I've this problem too, but mine is the stock firmware.I've no idea what causes those applications to launch themselves.
yes, a few of my friend also facing this problem. that is why i am thinking is some professional here can help us on this question.
Thanks
If you have rooted your phone, download this app called startup manager from market place, then disable these apps from the start up process. Viola, no more.
Seifer1975 said:
If you have rooted your phone, download this app called startup manager from market place, then disable these apps from the start up process. Viola, no more.
Click to expand...
Click to collapse
Is this startup manager for choosing which applications to auto start during soft reset only though?
You might also want to give "automatic task killer" from the market a go too, first app I would install after flashing roms.
Seifer1975 said:
If you have rooted your phone, download this app called startup manager from market place, then disable these apps from the start up process. Viola, no more.
Click to expand...
Click to collapse
I have installed startup manager application and already disable them at the startup. But they still coming back once a while when the phone is running......
I have successfully stop them from launch at the starting but after a while, it keep coming back. What is more irritating is once i kill them, they launch again 1-2 hours later....
i am thinking , is there any application running underground which keep "calling" them ?
After reading the help section on the system panel I installed, apparently the way android works is by loading up apps that it thinks you might need, so that when you do open them, they're already sitting there ready. system panel shows you a list of apps that are open on your phone and running, open but in the background, and those that on standby. Most task killers only show all these as being open, when they actually all aren't. The maker of the app strongly advises against continually killing all apps, unless any of them have a problem. Anyway, that's just what I read.
Nicolopolus; said:
After reading the help section on the system panel I installed, apparently the way android works is by loading up apps that it thinks you might need, so that when you do open them, they're already sitting there ready. system panel shows you a list of apps that are open on your phone and running, open but in the background, and those that on standby. Most task killers only show all these as being open, when they actually all aren't. The maker of the app strongly advises against continually killing all apps, unless any of them have a problem. Anyway, that's just what I read.
Click to expand...
Click to collapse
I see. Now it does explains everything. Sounds factual to me, if you've read it in the help section of the system panel. Thank you.
Facts are so important in problem solving.
Can you tell us which apps are started every hours like that ??
On my side I would like to know if the following app can be killed :
* Device management
* DRM protected content storage
* SNS
*com.sec.android.app.samsungapps.una
* com.sec.android.providers.downloads
*mobile AP settings
* Mobile Tracker settings
* Log provider
* My upload
* Settings
thanks

Some ideas for sensible task managers

No, this thread is not about all those "task managers" out there which will list Android's memory usage and offer (since Android 2.2 mostly useless) means to "kill" the apps in memory (iow remove them temporarily from memory).
It's about how we could offer something sensible from both technical and users point of views. Sadly Android seems to be lacking many required features, so ROM cooks might be required.
What Android lacks to offer, and what users seem to try to work around with task managers (or the wish for an "exit button"), are mainly two things:
1. A managable list of current tasks from a user's point of view, like "open windows" in Windows or Linux desktops, which can easily be "closed" or switched between ("Alt-Tab").
2. Information which app does something in background and ways to stop that, mostly to avoid lags and battery drain.
(Memory usage is something for nerds, and Android does a pretty good job for that already... )
So, my idea (with some ideas from posts of other people in this thread in Google's developers list) would be a task manager with three kinds of apps listed (separated or as one list with status indicators - open to discussion or different implementations...):
1. "open apps": listed from appearance of an Activity until "closed" in task manager or (if possible) left with Back button. Maybe it'd be sensible to ignore Activities which are omitted from "recent apps", to ignore e.g. spash screens or notification popups (like SMS popups from Handcent or ChompSMS).
2. "running apps": apps with a started service
3. "scheduled apps": apps which will receive scheduled AlarmManager broadcasts, with time of next broadcast and, for repeating alarms, interval.
For "running" and "scheduled" apps, some kind of "stop" button would be nice.
I don't think simply calling "stopService" is a good idea, since it could be respawned by the system, and removing AlarmManager entries might be a bad idea for functionality of some apps. Instead, some unified new Intent (e.g. app.package.STOP_BACKGROUND) is sent and handled by the app, which could then bring up own warnings. If the Intent is not handled, it would show something like "Stopping background work for this app is not supported. Please try to check its preferences."
For the "open apps", some kind of easy "Alt-Tab" would be cool, e.g. a special line in the notification drawer and/or replaced "(long) Home" handling.
Biggest technical problem is the "appearance of an Activity" and "finalized" (i.e. left with Back button) part for the "open apps". Maybe there also are some issues with querying the AlarmManager, I didn't go into detail there.
The Intent for "please stop any background work until next start (= appearance of Activity)" would be more of a communication than technical trouble.
What do you think about it?
Personally, I've never found a need for any kind of task manager yet. I do sometimes have to kill an errant app that I'm in the process of developing/debugging, but I usually screw things up so bad I need to reboot the phone anyway. Otherwise, the debugger cleans up pretty good when I re-launch whatever I'm developing.
As for normal user day-to-day task management, I find that the stock system does a pretty darn good job in my humble opinion.
I ran SystemPanel (Lite) briefly with stock 2.1, but found little use for it as a developer. Now with Froyo on my phone, I've not had any need for any kind of task manager

Apps randomly keep starting up in background

So ill go into my system panel and kill all apps. Ill have about 160mb of memory free. Then the launcher obviously restarts and system panel and my widgets all start back up, but what i dint hnderstand is why do thi gs like google voice or the music player start up in the background if i havent even used them? They start up almost instantly....
How can i make sure **** stays off?
Sent from my SGH-T959 using XDA Premium App
Start up manager or similar from the market. Take care though, if you block something that system wants to be launched, it may keep attempting to launch it, leading to high battery consumption
Some app include a service, which they are executed in background. If the service is maually stopped, android can launch it again.
There are many application on the market which stop periodically these app. The point is that if it has a service, there is a reason, and by stopping it, you can obtain a strange comportment.
By example, in the first version of Android, gtalk was used for the authentification on android market, it is very strange but it was like that. The user was not informed of this link which was a kind of transparent. So if you stopped gtalk, you were not able to go on the market.
Do you need a lot of RAM? If yes uninstall the application you don t use, but I advise you to not stop mannually or automatically the application on your phone.
I guess thats how android functions as such. I tried stopping these programs so many times using apps from the market, but it starts again n few minutes. So its like we are wasting our time trying to kill apps.
Autostarts and/or Android Optimizer will stop any unwanted apps from running constantly. Works for me but just make sure you know what you are doing so you don't stop something you need (as described above)..

Apps that runs on startup/background

I hate it when an app runs in the startup specially if the app is not that important. Is there any way of disabling those apps that run in the startup? As well as those apps that runs in the background even if you don't need em to? They eat up RAM and make the NC slow! I wish I can manage them.
Let them be android takes care of itself.
Read this: http://forums.androidcentral.com/general-help-how/102171-apps-always-running.html#post1088042
---
- Sent from my LG Optimus V using Tapatalk
les02jen17 said:
I hate it when an app runs in the startup specially if the app is not that important. Is there any way of disabling those apps that run in the startup? As well as those apps that runs in the background even if you don't need em to? They eat up RAM and make the NC slow! I wish I can manage them.
Click to expand...
Click to collapse
Yes...get an app in the market called Android Optimizer, it is free. In the menu hit the startup manager icon. Disable the app (s) you don't want to run at start up or background.
StarlahRain said:
Yes...get an app in the market called Android Optimizer, it is free. In the menu hit the startup manager icon. Disable the app (s) you don't want to run at start up or background.
Click to expand...
Click to collapse
You sure of that name? I did a search in the market and do not see it.
StarlahRain said:
Yes...get an app in the market called Android Optimizer, it is free. In the menu hit the startup manager icon. Disable the app (s) you don't want to run at start up or background.
Click to expand...
Click to collapse
You do not need an app like this. People use task killers and startup blockers and then complain about how crappy and slow stuff is because THEY ARE NOT ACTUALLY RUNNING IN THE BACKGROUND. They are cached for faster start up next time. They do not take up any battery or CPU power. Android is linex not windows.
--------------------------------------------------
Here is the post i linked to earlier:
I develop Android apps so I though I'd explain why a task killer isn't needed on an Android system.
Activities
Android apps use activites to preform tasks. For example, if you use a file manager to send a picture via email, the file manager calls the send activity within an email app, passes the file name to it and the email app sends the picture.. not the file manager. This will result in seeing the email app as "running" even though the user didn't actually launch that email app.
Smaller apps
Using activites helps developers design smaller apps. A file manager app that contains every bit of code needed to do everything a file manager does would likely be so large that no one would want to install it. Developers know that an android phone more than likely has an email app so there is no need for the developer to include email code in his/her file manager to send a picture when he/she can call an activity in an existing email app to do the job. This results in a smaller file manager app since there is no need to include email code or any other code for an activity that can be done via an app that is already present on the phone. This also alleviates redundant code. When you install an app outside of the android market, also known as sideloading, the file manager app calls the package installer (already present in Android) to install the requested app.
Running apps vs. cached apps
The "Manage Applications" list included in many android devices lists running apps as well as cached apps. Cached apps don't use any CPU or battery, they're cached so they will load faster the next time you need them. Killing cached apps results in those apps requiring more time to load the next time they are launched.
System management
By default, every android application runs in its own Linux process. Android starts the process when any of the application’s code (activities) needs to be executed, and shuts down the process when it’s no longer needed and system resources are required by other applications.
* Android is hard coded to automatically kill a task when more memory is needed.
* Android is hard coded to automatically kill a task when it’s done doing what it needs to do.
* Android is hard coded to automatically kill a task when you haven’t returned to it in a long time.
* Most services (while possibly running in the background) use very little memory when not actively doing something.
* A content provider is only doing something when there is a notification for it to give. Otherwise it uses very little memory.
* Killing a process when it isn’t ready only causes it to have to reload itself and start from scratch when it’s needed again.
* Because a task is likely running in the background for a reason, killing it will only cause it to re-spawn as soon as the activity that was using it looks for it again. And it will just have to start over again.
* Killing certain processes can have undesirable side effects. Not receiving text messages, alarms not going off, and force closes just to name a few.
* The only true way to prevent something from running at all on your phone would be to uninstall the .apk.
* Most applications will exit themselves if you get out of it by hitting “back” until it closes rather than hitting the “home” button. But even with hitting home, Android will eventually kill it once it’s been in the background for a while.
If you see an app running that you didn't launch, it's most likely because an activity within that app was called by another app to perform a task. If you kill the app you didn't launch, the system has to relaunch that app in order to complete its task. This is why some people kill a task and then see it immediately running again. Constantly killing that app creates a situation where the user is battling the system resulting in wasted system resources.
Android is Linux
Android is not a Windows-based OS, it is based on Linux. Many of the apps you think are running aren't actually running, they're cached, this is typical with a Linux operating system and is much more efficient than other systems. Cached apps don't use any CPU or battery, they're cached and will load faster the next time they're needed.
Let the system manage resources.
---
- Sent from my LG Optimus V using Tapatalk
patruns said:
You sure of that name? I did a search in the market and do not see it.
Click to expand...
Click to collapse
I apologize ..it is called Optimize Tool Box...lite version(free)...
koopakid08 said:
You do not need an app like this. People use task killers and startup blockers and then complain about how crappy and slow stuff is because THEY ARE NOT ACTUALLY RUNNING IN THE BACKGROUND. They are cached for faster start up next time. They do not take up any battery or CPU power. Android is linex not windows.
--------------------------------------------------
Here is the post i linked to earlier:
I develop Android apps so I though I'd explain why a task killer isn't needed on an Android system.
Activities
Android apps use activites to preform tasks. For example, if you use a file manager to send a picture via email, the file manager calls the send activity within an email app, passes the file name to it and the email app sends the picture.. not the file manager. This will result in seeing the email app as "running" even though the user didn't actually launch that email app.
Smaller apps
Using activites helps developers design smaller apps. A file manager app that contains every bit of code needed to do everything a file manager does would likely be so large that no one would want to install it. Developers know that an android phone more than likely has an email app so there is no need for the developer to include email code in his/her file manager to send a picture when he/she can call an activity in an existing email app to do the job. This results in a smaller file manager app since there is no need to include email code or any other code for an activity that can be done via an app that is already present on the phone. This also alleviates redundant code. When you install an app outside of the android market, also known as sideloading, the file manager app calls the package installer (already present in Android) to install the requested app.
Running apps vs. cached apps
The "Manage Applications" list included in many android devices lists running apps as well as cached apps. Cached apps don't use any CPU or battery, they're cached so they will load faster the next time you need them. Killing cached apps results in those apps requiring more time to load the next time they are launched.
System management
By default, every android application runs in its own Linux process. Android starts the process when any of the application’s code (activities) needs to be executed, and shuts down the process when it’s no longer needed and system resources are required by other applications.
* Android is hard coded to automatically kill a task when more memory is needed.
* Android is hard coded to automatically kill a task when it’s done doing what it needs to do.
* Android is hard coded to automatically kill a task when you haven’t returned to it in a long time.
* Most services (while possibly running in the background) use very little memory when not actively doing something.
* A content provider is only doing something when there is a notification for it to give. Otherwise it uses very little memory.
* Killing a process when it isn’t ready only causes it to have to reload itself and start from scratch when it’s needed again.
* Because a task is likely running in the background for a reason, killing it will only cause it to re-spawn as soon as the activity that was using it looks for it again. And it will just have to start over again.
* Killing certain processes can have undesirable side effects. Not receiving text messages, alarms not going off, and force closes just to name a few.
* The only true way to prevent something from running at all on your phone would be to uninstall the .apk.
* Most applications will exit themselves if you get out of it by hitting “back” until it closes rather than hitting the “home” button. But even with hitting home, Android will eventually kill it once it’s been in the background for a while.
If you see an app running that you didn't launch, it's most likely because an activity within that app was called by another app to perform a task. If you kill the app you didn't launch, the system has to relaunch that app in order to complete its task. This is why some people kill a task and then see it immediately running again. Constantly killing that app creates a situation where the user is battling the system resulting in wasted system resources.
Android is Linux
Android is not a Windows-based OS, it is based on Linux. Many of the apps you think are running aren't actually running, they're cached, this is typical with a Linux operating system and is much more efficient than other systems. Cached apps don't use any CPU or battery, they're cached and will load faster the next time they're needed.
Let the system manage resources.
---
- Sent from my LG Optimus V using Tapatalk
Click to expand...
Click to collapse
Yes..I have noticed some side effects.alarms and what not. I guess ur right the only real way is to completely uninstall the apk ..would u happen to know why my adw launcher keeps forceclosing each time boot my nook? I am not running any icon packages..so what other source (or app) could be calling on it to run at startup?
StarlahRain said:
Yes..I have noticed some side effects.alarms and what not. I guess ur right the only real way is to completely uninstall the apk ..would u happen to know why my adw launcher keeps forceclosing each time boot my nook? I am not running any icon packages..so what other source (or app) could be calling on it to run at startup?
Click to expand...
Click to collapse
I am not familiar with adw. Is there an option to save it in memory I know that many replacement launchers do so you might want to make sure that is checked.
Also if you are using a task killer, it is probably trying to kill it and that could cause it to force close.
---
- Sent from my LG Optimus V using Tapatalk
StarlahRain said:
Yes..I have noticed some side effects.alarms and what not. I guess ur right the only real way is to completely uninstall the apk ..would u happen to know why my adw launcher keeps forceclosing each time boot my nook? I am not running any icon packages..so what other source (or app) could be calling on it to run at startup?
Click to expand...
Click to collapse
Do you have Titanium Backup installed? You can clear data and uninstall apps with that as well.
auto starts kills those apps... i run it on my NC>.......i dont need dialer /voicemail...etc.....
Just a thought but if you continue to have force close issues with apps, try running fix permissions. This usually ends the issues. I run adw ex and have no problems. Those few times I have had issues, fix permissions has solved the problem. Just sayin.....
Sent from my NookColor using Tapatalk

Why some apps are only like a service?

Hi, why some default apps run only like a service? Gmail app and gtalk app runs only like a service...
And are some apps appear in Active Apps panel ans not appear in In Progress panel... Is very confusing... I'm not understand what app are running and consuming battery and memory...
Someone can help ?
If the cpu usage for app is 0%, it doesn't consume battery. And freeing memory doesn't help with battery drain, it's quite opposite. Try to find some threads here in "General" section with keywords: ram, multitasking, lmk, minfree...
Ps. Android isn't windows, so things work quite differently..
Sent from my GT-I9000 using xda premium
acazsouza said:
Hi, why some default apps run only like a service? Gmail app and gtalk app runs only like a service...
And are some apps appear in Active Apps panel ans not appear in In Progress panel... Is very confusing... I'm not understand what app are running and consuming battery and memory...
Click to expand...
Click to collapse
There is a difference between a service and a process.
A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity.
Click to expand...
Click to collapse
When an application component starts and the application does not have any other components running, the Android system starts a new Linux process for the application with a single thread of execution. By default, all components of the same application run in the same process and thread (called the "main" thread).... Every application runs in its own process and all components of the application run in that process, by default
Click to expand...
Click to collapse
The Android system tries to maintain an application process for as long as possible, but eventually needs to remove old processes to reclaim memory for new or more important processes. To determine which processes to keep and which to kill, the system places each process into an "importance hierarchy" based on the components running in the process and the state of those components. Processes with the lowest importance are eliminated first, then those with the next lowest importance, and so on, as necessary to recover system resources.
Click to expand...
Click to collapse
In a few words... Gmail and Talk are only services that are constantly monitoring incoming push data from the Google servers. There is also a WhatsApp, Google+, Music, Email, and many other services that are automatically started when an event triggers them. This depends on the app. Not all apps have services. For instance, a Live Wallpaper is a service, not a process. You should not kill those.
When you run an application, you start a process. This process holds all the UI and logic to display the application in your screen. If you press HOME on your phone, the process goes to inactive mode, and it "in theory" should stop using CPU cycles and will sleep in your RAM until you execute the app again, or until Android claims the RAM and kills the app. RAM does not kill your battery, CPU cycles do.
Source: http://developer.android.com/guide/topics/fundamentals.html
In a few words... Gmail and Talk are only services that are constantly monitoring incoming push data from the Google servers. There is also a WhatsApp, Google+, Music, Email, and many other services that are automatically started when an event triggers them. This depends on the app. Not all apps have services. For instance, a Live Wallpaper is a service, not a process. You should not kill those.
Click to expand...
Click to collapse
Why should not I kill them? I installed Germini App and stop GTalk and others to automatically init on boot.
up........

Categories

Resources