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) {

      }
}

Regards,
Manjunatha
--~--~---------~--~----~------------~-------~--~----~



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 implement JNI which calls a time consuming native method

I need to implement a JNI which render image with 3-party native
function.  This function call is time consuming, it cost about 1s to
return. I found during that time, even if I call the JNI within
another Java thread, the whole Dalvik VM is blocked. UI is frozen. I
guess that's because Dalvik doesn't implement Java thread with a
native thread, so any time consuming native function call will block
the whole VM.
I wonder how to solve this problem. My best guess is I should create a
pthread in JNI to call that 3-party native function. But I don't know
how to implement this kind of JNI.
Please help. Thanks!
--~--~---------~--~----~------------~-------~--~----~

2. How to determine a resource string is existing or not

Hi,
I want to determine a resource string is existing or not.
Because other programs in my system will build this string,
I need to check the string building is success or not.
If fail, I would replace this string as other string.

For example, if I want to get R.build.buildid

String updated;
if ( R.build.buildid is exist)
    updated = getString(R.build.buildid);
else
    updated = getString(R.string.none);//R.string.none exist

is it possible to check R.build.buildid is existing or not??
--~--~---------~--~----~------------~-------~--~----~

3. What kind of views are supported by the AppWidget framework?

4. race condition? Window already focused, ignoring focus gain of...

5. Need the function flow of Image capture and image viewer

6. Problem with Camera Picture display - Black screen on G1 :(

7. understanding the permission-group tag