致命异常:定时器0显示java.lang.NullPointerException [英] FATAL EXCEPTION: Timer-0 java.lang.NullPointerException

查看:1895
本文介绍了致命异常:定时器0显示java.lang.NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个计时器在OnCreate(),如:

I'm having a timer in the oncreate() like:

final Timer timer1 = new Timer();
timer1.schedule(new TimerTask() {
    public void run() {
        sendSMS();
    }
}, 20000);

该梅索德sendSMS()是这样的:

The methode sendSMS() is like:

private void sendSMS(){
    float test2;
    test2 = reallocation.getAccuracy(); //-> This is the line where logcat says.... NullPointerException
    ....
}

在logcat中说:

The logcat says:

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)

搜索网,我相信我需要计时器的处理程序后,嗯......但我不知道如何实现它。

Well after searching the net I believe I need a handler for the timer... but I have no clue how to implement it.

是否有人可以把我在正确的轨道上?

Does anybody can put me on the right track?!

推荐答案

重新分配未初始化,所以它取空值,默认的对象。

reallocation is uninitialized, so its taking the null value, the default one for object.

这篇关于致命异常:定时器0显示java.lang.NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆