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. oot Gmail Motion Exists, Just Not Done by Google!5788324/gmail-motion

watch it :


2. New Devloper - Need help with the most basic, Hello World!

Hi all

New to Android Devlopment - tried the first tutorial (Hello, Android):
it doesn't work! I've run it in the emulator - all i get is the
tipical android grey tect saying "android", much like a command promt.
I don't know if anything is set up correctly (Everything on the
devloper site followed word for word). Anyhow: here's the code:

package com.example.helloandroid;

import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        TextView tv = new TextView(this);
        tv.setText("Hello, Android");


Also, running windows 7.

All help will be very much appreciated!


Rob (emisnug)


3. custom dialog frame - how to get a pointy triangle edge

4. Detecting horizontal movement of phone

5. Backup Manager Error

6. To unsubscribe from this group, send email to

7. C/C++ Integration With Android...