2012-01-09 74 views
-1

我正在尝试使用BroadCastReceiver获取每半小时的GPS位置。但我有以下错误。Android应用程序中定时器函数的运行时错误?

错误消息

01-09 17:24:44.340: ERROR/AndroidRuntime(2324): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare(). 

我的代码

mTimer = new Timer(); 
    mTimerTask = new TimerTask() { 
    @Override 
    public void run() { 
     result();//here i cal the Gps function 
     } 
    }; 
    mTimer.scheduleAtFixedRate(mTimerTask,1000,50000); 

我的方法的结果()是没有得到调用。

+0

就像我在你以前的文章中所说的,这个问题在本网站上多次被询问和回答。重复http://stackoverflow.com/questions/3875184/cant-create-handler-inside-thread-that-has-not-called-looper-prepare – THelper 2012-01-09 12:20:13

+0

结果()做任何更改视图? – 2012-01-09 12:20:21

+0

没有理由我在这里得到纬度值 – user1138509 2012-01-09 12:22:21

回答

0

使用Handler in run()方法 .in处理程序句柄result();方法。

相关问题