android - NullPointerException when using LocalBroadcastManager -


i'm trying use localbroadcastmanager custom intents. seems it's picky intents , if send intent way:

in myintents.java declare

public static final string location_update = "com.example.myapp.location_update"; 

later on in broadcast sender do:

intent intent = new intent(myintents.location_update); localbroadcastmanager.sendbroadcast(intent); 

then i'm getting exception:

05-05 02:23:29.914: e/androidruntime(6952): fatal exception: main  05-05 02:23:29.914: e/androidruntime(6952): java.lang.nullpointerexception  05-05 02:23:29.914: e/androidruntime(6952): @ android.support.v4.content.localbroadcastmanager.executependingbroadcasts(localbroadcastmanager.java:297)  05-05 02:23:29.914: e/androidruntime(6952): @ android.support.v4.content.localbroadcastmanager.access$000(localbroadcastmanager.java:46)   05-05 02:23:29.914: e/androidruntime(6952): @ android.support.v4.content.localbroadcastmanager$1.handlemessage(localbroadcastmanager.java:116)  05-05 02:23:29.914: e/androidruntime(6952): @ android.os.handler.dispatchmessage(handler.java:99) 

however if use explicit string

intent intent = new intent("my-intent"); 

everything works fine.

what's wrong? why can't define intent name in class?

i came across this. npe result of registered listener (read: receiver) event firing (myintents.location_update) not having been instantiated component hosting it.

check thing want respond broadcast has been instantiated @ right point (probably hosting activity/fragment).


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -