广播接收机问题需要帮助?

时间:2011-08-01 06:39:51

标签: android broadcastreceiver

我尝试在AsyncTask类的内部类中创建广播接收器

这里是我的代码

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);
    }
}

我在AysncTask中的onPostExecuted中调用它

broadCast = new sendData();
        broadCast.send(MyGPS.location_info);

我得到错误作为力停止在我的程序中这主要是cuz null ponter异常,但我没有看到任何错误,任何想法?

这是我的日志猫

08-01 13:36:03.672: WARN/dalvikvm(509): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-01 13:36:03.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)

1 个答案:

答案 0 :(得分:0)

不要像这样创建活动broadCast = new sendData();