Blackberry 后台进程,带计时器,不中断用户界面
我有一个后台程序,可以计算一个位置的纬度和经度。然后,我使用计时器任务每隔几秒钟运行一次,以获得计算出的纬度和经度,并显示在RichMapField上。 我需要在地图上显示这个纬度和经度,但由于计时器的原因,它无法显示。 有人能告诉我如何处理这种情况吗 编辑: 请更好地理解:以下是我的代码: 每5秒计划一次的计时器:Blackberry 后台进程,带计时器,不中断用户界面,blackberry,maps,blackberry-maps,Blackberry,Maps,Blackberry Maps,我有一个后台程序,可以计算一个位置的纬度和经度。然后,我使用计时器任务每隔几秒钟运行一次,以获得计算出的纬度和经度,并显示在RichMapField上。 我需要在地图上显示这个纬度和经度,但由于计时器的原因,它无法显示。 有人能告诉我如何处理这种情况吗 编辑: 请更好地理解:以下是我的代码: 每5秒计划一次的计时器: timer.scheduleAtFixedRate(new TimerTask() { public void run() {
timer.scheduleAtFixedRate(new TimerTask() {
public void run()
{
currentLocation.run();
}}, 0, 5000);
public Runnable currentLocation = new Runnable()
{
public void run() {
double[] coordinates = new double[3];
coordinates[0]= 47.674131297119935;
coordinates[1]= 9.384496898485185;
coordinates[2]= 475.678;
addToMap(coordinates);
}
};
public void addToMap(double[] coordinates)
{
MapLocation location1 = new MapLocation(coordinates[0],coordinates[1],"My Location2",null);
int location1ID = data.add((Mappable)location1,"My");
data.tag(location1ID, "Location1");
MapLocation location2 = new MapLocation(coordinates[0],coordinates[1],"My Location2",null);
int location2ID = data.add((Mappable)location2,"My");
data.tag(location2ID, "Location2");
}
您是否收到任何错误或只是没有显示?我没有收到任何错误,它没有显示,计时器正在阻止要添加到地图上的纬度和经度,例如,ex计时器计划每5秒一次。实际附加/显示地图位置的代码在哪里?