4

Possible Duplicate:
Android RuntimeException: Unable to instantiate the service

I can't find a way to start IntentService from AlarmManager. It is simple for normal service (add it to the manifest, then wrap it up in Intent), but I can't make it work with IntentService - app keeps crashing with "java.lang.RuntimeException: Unable to instantiate service". There is nothing wrong with the IntentService itself (1 line of code). Any help?

Community
  • 1
  • 1
jacek
  • 947
  • 1
  • 11
  • 20

1 Answers1

6

There should be no problem to fire IntentService from AlarmManager, and I did it more than once. In the case of IntentService I met cases where a few lines of code were enough to make the problem.

Make sure your IntentService has a constructor like that:

    public MyIntentService() {
        super("MyIntentService");
    }

Because alarm manager will try to instantiate it with no parameters, and the original IntentService constructor receives String as a parameter.

Stephane Rolland
  • 38,876
  • 35
  • 121
  • 169
MByD
  • 135,866
  • 28
  • 264
  • 277