我有在OnCreate()之类的计时器:
final Timer timer1 = new Timer();
timer1.schedule(new TimerTask() {
public void run() {
sendSMS();
}
}, 20000);
所述梅索德sendSMS()是这样的:
private void sendSMS(){
float test2;
test2 = reallocation.getAccuracy(); //-> This is the line where logcat says.... NullPointerException
....
}
该logcat的说:
05-30 18:32:26.962: W/dalvikvm(741): threadid=9: thread exiting with uncaught exception (group=0x4001d5a0)
05-30 18:32:26.972: E/AndroidRuntime(741): FATAL EXCEPTION: Timer-0
05-30 18:32:26.972: E/AndroidRuntime(741): java.lang.NullPointerException
05-30 18:32:26.972: E/AndroidRuntime(741): at com.eljoom.df.ActionGPS.sendSMS(ActionGPS.java:280)
搜索网后好了,我相信我需要计时的处理程序......但我不知道如何实现它。
是否有人可以把我在正确的轨道上?