我想通过使用时间轴广告 lambda 表达式进行定期处理。我已经成功地在桌面上测试了实现(见下文)。但是当我通过 Eclipse 和安装 gradle 任务(Gluon + javafxports)为 Android 生成它时它不起作用。处理一直有效。结果:我认为这就是为什么在测试期间无法在我的手机上检测到触觉触摸屏的原因。
使用java代码:
static long BDTapplication = 110; // in ms
static long nbBDT = 0;
static long t0 = System.currentTimeMillis();
/********************************************************/
public static void periodicProcessing() {
nbBDT++;
traceWithSystemTime("periodicProcessing / nbBDT: " + nbBDT);
}
/********************************************************/
public static void traceWithSystemTime(String comments) {
long t = System.currentTimeMillis();
long deltaT =t - t0;
System.out.println("time - t0: " + t0 + " / t: "+ t + " / detaT: " + deltaT + " ms --- " + comments);
}
/************************************************* *******/
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World sur Android! -------------->>>>>>>>>>>>>>>>>>>");
// Timeline and BDT - section with pb
Timeline traittBDTapplication = new Timeline(
new KeyFrame(Duration.millis(BDTapplication), ae ->periodicProcessing()));
traittBDTapplication.setCycleCount(Timeline.INDEFINITE);
traittBDTapplication.play();
// End of section pb
I/System.out(23475): 时间 - t0: 1484454901468 / t: 1484454903224 / detaT: 1756 ms --- Fin du 测试
I/System.out(23475): 时间 - t0: 1484454901468 / t: 1484454903226 / detaT: 1758 ms --- 周期性处理 / nbBDT: 1
I/System.out(23475): time - t0: 1484454901468 / t: 1484454903226 / detaT: 1758 ms --- periodicProcessing / nbBDT: 2
I/System.out(23475): time - t0: 1484454901468 / t: 1484454903226 / detaT: 1758 ms --- periodicProcessing / nbBDT: 3
Several periodicProcessing methods are called in loop in a single 1758 ms whereas each of them should be called at every 110 ms
I have tried other solutions like for avoiding to use the lambda expression, ...., results are the same: no periodic event is generated. But, in any case, these solutions work on desktop.
Question: how to write a periodic call by using JavaFx for Android smartphones?