I just posted the link below in another thread.
http://stackoverflow.com/questions/6363207/android-background-service-to-determine-foreground-application
It might be useful for you too.

On Nov 16, 12:22 am, Bateman <7thharmo...@gmail.com> wrote:
> Hi,
> I want to detect the currently executing foreground app. If the
> foreground app is say "email" then perform some tasks.
> I tried doing this from within the android frame work. However, the
> only way to do it is using Activity Manager and checking the running
> tasks periodically from a background service. However, running this
> background service periodically will not be good as it will consume
> battery and might hog the cpu if the check period is low.
>
> Instead of doing it from the android framework, is there any way I can
> do this from within the kernel?
> I can check the list of tasks in the run-queue. I can also check what
> task is being context-switched in.
> However, even while an app is running it will be getting context-
> switched in and out. Hence I will have to differentiate the context-
> switch in for the first time and the context-switches occurring during
> the execution of the application.
> Can anyone give me some feedback on this.
>
> Thanks.

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-kernel

Reply via email to