开发者

IntentService and AlarmManager [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

Android RuntimeException: Unable to instantiate the service

I can't find a way to start IntentService from AlarmManager. It is simple开发者_StackOverflow社区 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜