Stopping all services..

by greggnic » Fri, 10 Apr 2009 01:40:20 GMT


Sponsored Links
 Hi,

I just started writing an application for android and have run into a
wall. I would like my program to wait a certain amount of time and
then stop all currently running services. This would be useful when
falling asleep and you want to listen to music for say 30 minutes and
then the music player turns off automatically. I have tried this bit
of code:

                ActivityManager am = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);

                List<ActivityManager.RunningServiceInfo> myList =
am.getRunningServices(20);

                for(int i=0; i < myList.size(); i++){

                        //Toast.makeText(context, myList.get(i).process,
Toast.LENGTH_LONG).show();
                        android.os.Process.killProcess(myList.get(i).pid);
                 }

However, this does not work. Does anyone have a better way to do this
or any suggestions? Thanks,

-Nick

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



Stopping all services..

by Mark Murphy » Fri, 10 Apr 2009 06:12:08 GMT


 


IMHO, that would be a rather significant security issue.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books.html 

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


Sponsored Links


Stopping all services..

by greggnic » Fri, 10 Apr 2009 07:45:38 GMT


 I see your point and definitely agree. I would really like to see a
sleep timer function for the music player though and don't think I
would be able to write a whole music player application that could
compete with the others out there...





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



Stopping all services..

by Mark Murphy » Fri, 10 Apr 2009 08:17:39 GMT


 


Well, the built-in music player is open source:

 http://android.git.kernel.org/?p=platform/packages/apps/Music.git ;a=tree

In principle, you could make a sleep-timer patch and submit it:

 http://source.android.com 

Admittedly, there is a learning curve for making changes to the source
code, more so than with many open source projects, due to the unusual
build environment and the unusual patch submission process. I haven't
climbed that curve myself.

Another possibility would be for you to create an application that let
users configure sleep timers and, when the timer elapsed, broadcast an
Intent that confirming applications would pay attention to and honor.
You might partner with OpenIntents.org, as this seems like their sort of
application, and you might be able to help get some prominent
third-party applications, such as some music players, to honor your
sleep-timer Intent. This requires as much people skills as coding
skills, though, to convince other developers to follow your sleep-timer
lead.

There are probably other ways to go about this as well -- those are just
two off the top of my head.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

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



Other Threads

1. facebook android 2.0 was Jubeh Android 2.0 buat dream

Bagi apknya dong bro,sapa tau bisa buat donut ato cupcake

sent from magix donut





guys

fb android 2.0 ini punya kemampuan untuk sync contact, ini bisa ditaro
di ROM 1.5/1.6 ga ya?

barusan coba, seneng juga liat contact sync dari FB qeqeqeq...

tku


--~--~---------~--~----~------------~-------~--~----~
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

2. facebook android 2.0 was Jubeh Android 2.0 buat dream

Thank you bos dzikki :-)


Sent powered by Sinyal Kuat INDOSAT

-----Original Message-----
From: Dzikki Muhammad <dzikki.gad...@gmail.com>
Date: Fri, 20 Nov 2009 09:06:39 
To: <id-android@googlegroups.com>
Subject: Re: facebook android 2.0 was Re: [id-android] Re: Jubeh Android 2.0 
 buat dream

ini file facebooknya, saya ambil dari android AOSP2.0 yang diextract.
ketika saya install ada pilihan untuk sync contact, ga tau ini karena
facebooknya atau karena ROM nya.

saya belum coba juga :p
have fun




--~--~---------~--~----~------------~-------~--~----~
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

3. How can I change the look of the front screen of the Android?

4. pressed image not showing !

5. How do I create a jar containing the .class files in bin?

6. android.R.drawable.ic_menu_home - can not use

7. Talking to service Daemons / init.rc help