我正在创建一个应用程序,它使用 GPS 跟踪用户位置,将经度和纬度存储在 SQLite 数据库中并添加接近警报。
参考 - http://www.javacodegeeks.com/2011/01/android-proximity-alerts-tutorial.html
错误消息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);