J'utilise AndroidAnnotations et j'ai quelques IntentServices. Je reçois parfois cette erreur (qui se passe sur tous les services, pas seulement celui ci-dessous):Exception de pointeur nul à l'intérieur de IntentService généré
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)
Mais je ne peux pas vérifier si l'intention est nul parce que DataLoaderService_
est généré et non modifiable.
Comment puis-je résoudre ce problème?
EDIT: Ceci est un exemple de la façon dont ce service est appelé:
DataLoaderService_.intent(MyApplication.getContext()).loadMyData().start();
Et c'est le service (généré):
@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;
}
}
Veuillez écrire le code qui appelle cet IntentService. – Egor
Publié le code – fanboy555
Copie possible de [Qu'est-ce qu'une NullPointerException, et comment puis-je le réparer?] (Http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i -fix-it) – Ironman