Get notified when a process end or is killed on Android
-
I've been digging the web in quest of finding nice, androidish solution for this concrete problem, but havent found one, so here I am, posting my first question on StackOverflow. To elaborate on my problem, I have a full-fledged aidl service, to which some other processes bind. My service will allocate some resources for each of process connecting to it, and I want to make this statement bold, the resource allocation is made for process, I make some kind of a session tracking, where getCallingPid() and getCallingUid() play a role of session identifiers. So the problem here is that Android will never tell us if an application which was bound to us went away for some reason, so the system resources allocated for that destroyed process would be wasted away by being held by our service. One solution that I found somewhat feasible is just to poll http://developer.android.com/reference/android/app/ActivityManager.html#getRunningAppProcesses%28%29 and calculate set difference between current and previous snapshots, but this method looks really dirty. Could anyone suggest some better method to do this? I'd be really grateful! Thanks, Giorgi
-
Answer:
As far as I'm aware, Android won't tell you when processes are killed. I suspect the only method is to get a list of running applications every x seconds or minutes, and keep track of the applications that way. I think this is what you already suggested in the question as well. It's not pretty, but it's likely one of the only ways to do it.
Giorgi at Stack Overflow Visit the source
Related Q & A:
- Why does the connection break when I kill a process on remote host?Best solution by Server Fault
- How to get the column value when a row is selected in wpf listview?Best solution by Stack Overflow
- How to create a process in Android?Best solution by Stack Overflow
- What do I do, when I get bitten by a mosquito?Best solution by Yahoo! Answers
- How can I get inbound/outbound call process?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.