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

by Kakyoin » Tue, 18 Nov 2008 00:22:19 GMT


Sponsored Links
 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. Smile

--~--~---------~--~----~------------~-------~--~----~



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

by hackbod » Tue, 18 Nov 2008 03:11:25 GMT


 To auto-stop when the user launches another app (I assume from your
own), you can just look at the pause or stop call of your own
activities.

For starting when other apps are "closed", there is no way to do this,
it really isn't in the Android application model.  It is completely
normal for a user to leave all applications "open" (a very nebulous
concept of android) forever.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. want to unsubscribe from this group

Hi there
Thank you for all the help,
I want to unsubscribe from this group.

-- 


Thanks & Regards
Somashekhar V. Dhanashree
+91-9535162978

-- 

2. Problems with orientationchange

Hello,
I have a tabactivity where my app is running in. One of the tabs needs
to have landscape orientation, assume this is activity2, activity1
needs to have portrait-orientation.

In activity1 I do have code like:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(this.getRequestedOrientation() ==
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
 
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

And in activity2:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(this.getRequestedOrientation() ==
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
 
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}

So when I now want to change from activity1 to activity2. It seems as
my app is in a infinite-loop, it tries to start activity2 again and
again, but it doesnt appear. I dont get an exception either!

Is that some know bug of android or am I doing something wrong. Help a
appreciated a lot.

Thanks

-- 

3. How to create new page / form

4. Trying to delete google account programmatically from my app.

5. CLOSED WTA : hapus file di /cache

6. Cannot load kml files through Emulator Control in Eclipse..

7. Update : Nama Pemesan Gantungan Kunci ( Kloteran ditutup )