Java 如何在特定时间段后将新url加载到web视图中?
我有一个Java 如何在特定时间段后将新url加载到web视图中?,java,android,webview,Java,Android,Webview,我有一个模型的数组列表,其中包含-->键:{link:…,duration:…}。 我需要在浏览完我的数组列表中的所有链接之后加载我的androidweb视图,并在特定的持续时间内加载它们 更新: 我尝试了处理程序,但它仍然加载最后一个网页并生成线程。sleep()在数组长度限制的循环中挂起应用程序,I=0;i您可以使用特定时间间隔的timerTask来加载列表URL private static Timer timer; private TimerTask timerTask;
模型的数组列表
,其中包含-->键:{link:…,duration:…}
。
我需要在浏览完我的数组列表中的所有链接之后加载我的androidweb视图
,并在特定的
持续时间内加载它们
更新:
我尝试了处理程序,但它仍然加载最后一个网页并生成线程。sleep()在数组长度限制的循环中挂起应用程序,
I=0;i您可以使用特定时间间隔的timerTask来加载列表URL
private static Timer timer;
private TimerTask timerTask;
public void startTimer() {
//set a new Timer
try {
timer = new Timer();
//initialize the TimerTask's job
initializeTimerTask();
//schedule the timer, to wake up every 2 second
timer.schedule(timerTask, AppConstants.bgTaskStartDelay, 2000); //
} catch (Exception e) {
e.printStackTrace();
}
}
// it sets the timer to print the counter every x seconds
public void initializeTimerTask() {
timerTask = new TimerTask() {
public void run() {
try {
// you code here to load url from your array
} catch (Exception e) {
e.printStackTrace();
}
}
};
}
可能您需要观察列表是否为空,或者当所有链接都已通过时。你能分享模式的详细信息吗?尝试过了,但网页视图仍然显示最后一个网页显示你的代码你正在做什么和你想做什么。API中缺少一些端点,给了我错误的列表。泰克斯:这真是个奇迹。
private static Timer timer;
private TimerTask timerTask;
public void startTimer() {
//set a new Timer
try {
timer = new Timer();
//initialize the TimerTask's job
initializeTimerTask();
//schedule the timer, to wake up every 2 second
timer.schedule(timerTask, AppConstants.bgTaskStartDelay, 2000); //
} catch (Exception e) {
e.printStackTrace();
}
}
// it sets the timer to print the counter every x seconds
public void initializeTimerTask() {
timerTask = new TimerTask() {
public void run() {
try {
// you code here to load url from your array
} catch (Exception e) {
e.printStackTrace();
}
}
};
}