broadcast receiver issue need help ?
I try to create a broadcast receiver in inner-class of AsyncTask class
here my code
public class sendData extends Activity {
private Intent myFiltered;
public void send(String loc){
myFiltered = new Intent(GPS_FILTER);
myFiltered.putExtra("location_info_post", loc);
this.sendBroadcast(myFiltered);
}
}
n i call it in onPostExecuted in AysncTask
broadCast = new sendData();
broadCast.send(MyGPS.location_info);
I got error as force to stop in my program n this mainly cuz null ponter exception but i don't see any error , any idea??
here my log cat
08-01 13:36:03.672: WARN/dalvikvm(509): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-01 13:36:0开发者_开发问答3.753: ERROR/AndroidRuntime(509): FATAL EXCEPTION: main
08-01 13:36:03.753: ERROR/AndroidRuntime(509): java.lang.NullPointerException
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:271)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at project.bm.setting.sendGPS$sendData.send(sendGPS.java:108)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at project.bm.setting.sendGPS.onPostExecute(sendGPS.java:85)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at project.bm.setting.sendGPS.onPostExecute(sendGPS.java:1)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at android.os.AsyncTask.finish(AsyncTask.java:417)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at android.os.AsyncTask.access$300(AsyncTask.java:127)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at android.os.Looper.loop(Looper.java:123)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at java.lang.reflect.Method.invoke(Method.java:521)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-01 13:36:03.753: ERROR/AndroidRuntime(509): at dalvik.system.NativeStart.main(Native Method)
Don't create Activity like this broadCast = new sendData();
精彩评论