0
我嘗試在內部類的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);
}
}
妮叫它onPostExecuted在AysncTask
broadCast = new sendData();
broadCast.send(MyGPS.location_info);
我得到了錯誤的力量停止在我的程序n這主要是cuz空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)
那麼,如何才能創造它? – sayvortana
其實我宣佈廣播作爲一個Class類型送出數據的構件,它的確定申報一樣, – sayvortana
活動可以通過意向打開。你不應該手動創建它們。 – Maxim