Android错误:Can';t在未调用Looper.prepare()的线程内创建处理程序
我正在单击事件中创建一个线程。我想在特定时间重复调用我的Web服务,这就是为什么我在click事件中使用Timer事件,但它引发了一个异常,即java.lang.RuntimeException:无法在未调用Looper.prepare()的线程中创建处理程序。 如果我不能在点击事件中调用计时器,请给我一些提示 这是我的密码Android错误:Can';t在未调用Looper.prepare()的线程内创建处理程序,android,timer,Android,Timer,我正在单击事件中创建一个线程。我想在特定时间重复调用我的Web服务,这就是为什么我在click事件中使用Timer事件,但它引发了一个异常,即java.lang.RuntimeException:无法在未调用Looper.prepare()的线程中创建处理程序。 如果我不能在点击事件中调用计时器,请给我一些提示 这是我的密码 holder.linear.setOnClickListener(new OnClickListener() { public void onCl
holder.linear.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (mo.equals(BUDDYNAMECOPY.get(BUDDYNAMECOPY.indexOf(mo)))) {
INDEX = BUDDYNAMECOPY.indexOf(mo);
B_Id = BUDDYLIST.get(INDEX).getBuddyUID();
tim.schedule(new TimerTask() {
@Override
public void run() {
CurrentLocation location =new CurrentLocation(getApplicationContext());
lat=location.getCurrentLatitude();
lon=location.getCurrentLongitude();
String url=UrlConstant.BASEURL + UrlConstant.GET_LATLONG
+ JsonDataProcessor.uid + "&buddy_uid="
+ B_Id;
JsonDataProcessor caller=new JsonDataProcessor(url,BuddyList.this,UrlConstant.BUDDYLOCATION);
}
},0,30000);
}
}
});
你有没有找到解决办法?我也有同样的问题,我面临着同样的错误。正确的解决方案是什么?你有没有找到解决方案?我也有同样的问题,我面临着同样的错误。正确的解决方案是什么?