Restarting a service.

by M.Manjunatha » Wed, 29 Apr 2009 20:44:52 GMT

Sponsored Links
 Hi Folks,

How do I restart my service automatically when my service gets killed
or crashes, until and unless I myself deregister the service.

public class Myservice extends Service {

      public void Myservice(){

      public void onStart(Intent intent, int startId) {



Restarting a service.

by Todd Sjolander » Thu, 30 Apr 2009 22:47:45 GMT

 As I understand it, if your Service (or Activity, for that matter),
dies due to the system reclaiming resources or a crash, the OS will
restart it for you automatically.  That means if you were to configure
it to start upon boot (using android.permission.RECEIVE_BOOT_COMPLETED
and implementing a receiver that handles
android.intent.action.BOOT_COMPLETED), you could be pretty certain
that your service is always running...once the user restarts the phone
after installation.  Or if you have some kind of user interface for
the product (can't see how you wouldn't!), it could start the service
if it isn't already running.  Then there wouldn't be a restart needed.

Todd Sjolander


Sponsored Links

Other Threads

1. How to add a new LOCALE for localization?

Hi all,

I have successful build Android 1.5 and installed on my G1. But I was
wondering if someone could point me to which file that I need to add a
new locale for my own language, .e.g Lao, language code lo-LA.
Currently there are many locales shown under the build.

2. ContentResolver query Grammar

String phonenumberString=PhontUliti.formatPhoneNumber(number);
            String[] contactsProjection=new String[]
            Cursor contactsCursor=context.getContentResolver().query
                           contactsProjection, People.NUMBER +" = " 
                           null, People.DEFAULT_SORT_ORDER);

Why the contactsCursor is null?
The number is in   the contacts.
Is there any mistakks in the query?

3. singletask activity for games

4. How to log test results in a file? - logcat error

5. Sending calendar events via MMS

6. AudioRecord cannot capture audio on beagle board?

7. Access to opencore audio decoders from application layer.