How to make a Service run ONLY when no other app is running?

Put your problem here if it does not fit any of the other categories.

How to make a Service run ONLY when no other app is running?

Postby lgmcben » Mon Nov 17, 2008 8:15 am

I've successfully created a service that change the wallpaper every 2 seconds.

My next goals:

I want this service to...

- auto-stop itself when user launch other app.
- auto-start itself when the wallpaper is visible. (eg. when users close all other apps)

The only clue I have is, when user press the device's "home" button, Android will launch an activity of category "Android.intent.category.HOME".

Which can help me a bit but obviously not enough (as pressing back button also make wallpaper visible, but no event fired)

Any recommendations are welcome.

Thank you in advance. :)
lgmcben
Junior Developer
Junior Developer
 
Posts: 24
Joined: Mon Nov 17, 2008 5:06 am

Top

Postby MrSnowflake » Mon Nov 17, 2008 11:57 am

I don't know if there is an accessible Activity stack, but try to look for it and when the Home app is on top do your stuff in the service, otherwise sleep(1000) and check again (a wait of 1 sec should slow down the phone :)) .
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 28 guests