I'm using AndroidAnnotations and I have a few IntentServices. I sometimes get this error (happens on all Services, not just the one below):
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference
at xxxx.DataLoaderService_.onHandleIntent(DataLoaderService_.java:51)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
But I can't check if Intent is null because DataLoaderService_
is generated and not editable.
How can I solve this problem?
EDIT: This is an example of how this service gets called:
DataLoaderService_.intent(MyApplication.getContext()).loadMyData().start();
And this is the service (generated):
@Override
public void onHandleIntent(Intent intent) {
DataLoaderService_.super.onHandleIntent(intent);
String action = intent.getAction();
if (ACTION_LOAD_MY_DATA.equals(action)) {
super.loadMyData();
return ;
}
}
public static class IntentBuilder_
extends ServiceIntentBuilder<DataLoaderService_.IntentBuilder_>
{
public DataLoaderService_.IntentBuilder_ loadMyData() {
action(ACTION_LOAD_MY_DATA);
return this;
}
}