2012-04-17 102 views
1

我創建一個應用程序,它跟蹤使用GPS的用戶的位置,存儲在SQLite數據庫的經度和緯度,並增加了接近警報。
參考 - http://www.javacodegeeks.com/2011/01/android-proximity-alerts-tutorial.htmlNullPointerException異常接近警報

ERROR消息java.lang.NullPointerException
logcat的:

04-19 08:14:42.617: W/IInputConnectionWrapper(585): showStatusIcon on inactive InputConnection 
04-19 08:18:18.477: W/IInputConnectionWrapper(585): showStatusIcon on inactive InputConnection 
04-19 08:18:26.717: D/dalvikvm(585): GC_EXPLICIT freed 3939 objects/240736 bytes in 1956ms 
04-19 08:18:37.947: W/KeyCharacterMap(636): No keyboard for id 0 
04-19 08:18:37.947: W/KeyCharacterMap(636): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 
04-19 08:18:46.638: D/AndroidRuntime(636): Shutting down VM 
04-19 08:18:46.638: W/dalvikvm(636): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 
04-19 08:18:46.677: E/AndroidRuntime(636): FATAL EXCEPTION: main 
04-19 08:18:46.677: E/AndroidRuntime(636): java.lang.NullPointerException 
04-19 08:18:46.677: E/AndroidRuntime(636): at com.sql.SQLiteExample.saveProximityAlertPoint(SQLiteExample.java:157) 
04-19 08:18:46.677: E/AndroidRuntime(636): at com.sql.SQLiteExample.onClick(SQLiteExample.java:107) 
04-19 08:18:46.677: E/AndroidRuntime(636): at android.view.View.performClick(View.java:2408) 
04-19 08:18:46.677: E/AndroidRuntime(636): at android.view.View$PerformClick.run(View.java:8816) 
04-19 08:18:46.677: E/AndroidRuntime(636): at android.os.Handler.handleCallback(Handler.java:587) 
04-19 08:18:46.677: E/AndroidRuntime(636): at android.os.Handler.dispatchMessage(Handler.java:92) 
04-19 08:18:46.677: E/AndroidRuntime(636): at android.os.Looper.loop(Looper.java:123) 
04-19 08:18:46.677: E/AndroidRuntime(636): at android.app.ActivityThread.main(ActivityThread.java:4627) 
04-19 08:18:46.677: E/AndroidRuntime(636): at java.lang.reflect.Method.invokeNative(Native Method) 
04-19 08:18:46.677: E/AndroidRuntime(636): at java.lang.reflect.Method.invoke(Method.java:521) 
04-19 08:18:46.677: E/AndroidRuntime(636): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
04-19 08:18:46.677: E/AndroidRuntime(636): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
04-19 08:18:46.677: E/AndroidRuntime(636): at dalvik.system.NativeStart.main(Native Method) 

錯誤代碼行:

saveProximityAlertPoint(location1,longi, lati); 
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); 
+0

在會發生什麼呢?如果你沒有日誌添加調試打印和找出。 IT對我們所有人來說都會更容易。 – MByD 2012-04-17 06:51:46

+0

@BinyaminSharet請參閱日誌文件 – madwhoo 2012-04-17 18:55:08

回答

1

構件locationManager其中調用saveProximityAlertPoint()locationManager失敗的初始化未初始化。