本文整理匯總了Java中java.util.Timer.schedule方法的典型用法代碼示例。如果您正苦於以下問題:Java Timer.schedule方法的具體用法?Java Timer.schedule怎麽用?Java Timer.schedule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Timer
的用法示例。
在下文中一共展示了Timer.schedule方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doResume
import java.util.Timer; //導入方法依賴的package包/類
@Override
protected void doResume() {
commandExecutionTimer = new Timer();
commandExecutionTimer.schedule(new TimerTask() {
@Override
public void run() {
Intent intent = new Intent();
intent.setAction(BackgroundMusicBroadcastReceiver.ACTION_PLAY);
getContext().sendBroadcast(intent);
}
}, 600L);
int timeLeft = getBackgroundService().getDuration() - getBackgroundService().getCurrentPosition();
Log.d(this.getClass().getName(), "TimeLeft after resume: " + timeLeft + " duration: " + getBackgroundService().getDuration() + " curPos: " + getBackgroundService().getCurrentPosition());
startTimer(timeLeft + getSilenceDuration());
}
示例2: onCreate
import java.util.Timer; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
TimerTask task = new TimerTask() {
@Override
public void run() {
finish();
startActivity(new Intent(Splash.this, LoginActivity.class));
}
};
Timer opening = new Timer( );
opening.schedule(task,2000);
}
示例3: startMp4
import java.util.Timer; //導入方法依賴的package包/類
public void startMp4(File f) {
mVideoFragment = VideoFragment.newInstance(f.getPath(), true);
transaction.add(R.id.init_frame, mVideoFragment, "initVideo").commit();
exitTimer = new Timer();
exitTimer.schedule(new TimerTask() {
@Override
public void run() {
videoTime--;
InitStartActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (exitInit != null) {
exitInit.setText(mWeApplication.getResources().getString(R.string.exit_init) + videoTime);
if (videoTime <= 0) {
HomeActivity.show(InitStartActivity.this);
InitStartActivity.this.finish();
}
}
}
});
}
}, 0, 1 * 1000);
}
示例4: activateOptions
import java.util.Timer; //導入方法依賴的package包/類
@Override
public void activateOptions() {
connectionTimeout = connectionTimeout < DEFAULT_CONNECTION_TIMEOUT ? DEFAULT_CONNECTION_TIMEOUT : connectionTimeout;
readTimeout = readTimeout < DEFAULT_READ_TIMEOUT ? DEFAULT_READ_TIMEOUT : readTimeout;
cacheFlushTime = cacheFlushTime < DEFAULT_CACHE_FLUSH_TIME ? DEFAULT_CACHE_FLUSH_TIME : cacheFlushTime;
maxCacheSize = maxCacheSize < EventCache.DEFAULT_MAX_SIZE ? EventCache.DEFAULT_MAX_SIZE : maxCacheSize;
eventCache.setSize(maxCacheSize);
Timer timer = new Timer("async-http-appender-daemon",true);
timer.schedule(new TimerTask() {
@Override
public void run() {
sendEventsAsync();
}
}, cacheFlushTime, cacheFlushTime);
}
示例5: onGuildMessageReceived
import java.util.Timer; //導入方法依賴的package包/類
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
String en = SQL.getValue(event.getGuild(),"joinchannel");
Timer timer = new Timer();
Date date=new Date();
if (!event.getAuthor().isBot() && event.getAuthor().getId() != event.getJDA().getSelfUser().getId()) {
count++;
}
timer.schedule(new TimerTask(){
public void run(){
if (!en.equals("0")) {
event.getJDA().getTextChannelById(en).sendMessage("Today i count " + count + " Messages!").queue();
}
}
},date, 24*60*60*1000);
}
示例6: onMessage
import java.util.Timer; //導入方法依賴的package包/類
/**
* Client onMessage get called to kill the job
* @param message
* @param session
*/
@OnMessage
public void onMessage(String message, Session session) {
logger.info("Trying to kill the job");
final Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
if (execution != null) {
logger.info("Job killed successfully");
execution.kill();
timer.cancel();
}
}
};
timer.schedule(task, 0l, 600);
}
示例7: onCreate
import java.util.Timer; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
// 透明狀態欄
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 透明導航欄
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
setContentView(R.layout.loading);
final Intent intent = new Intent(this, App.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
startActivity(intent);
finish();
}
};
timer.schedule(task, 1000);// 此處的Delay可以是3*1000,代表三秒
}
示例8: saveFile
import java.util.Timer; //導入方法依賴的package包/類
private void saveFile(final File file) {
isDraw = false;
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
try {
image = robot.createScreenCapture(getNormalRect());
String name = file.getName();
ImageIO.write(image, name.substring(name.indexOf(".") + 1), file);
} catch (IOException ex) {
Logger.getLogger(ScreenCut.class.getName()).log(Level.SEVERE, null, ex);
} finally {
dispose();
}
}
}, 50);
}
示例9: init
import java.util.Timer; //導入方法依賴的package包/類
public void init(FilterConfig config) throws ServletException
{
SYSTEM_REFRESH = getToLong(config.getInitParameter("refreshTime"), 3600000L);
PAGE_NOACCESS = getToString(config.getInitParameter("forbiddenPage"), "");
splitToSet(getToString(config.getInitParameter("ignorePage"), ""), PAGE_IGNORE);
splitToSet(PAGE_NOACCESS, PAGE_IGNORE);
CHECK_FIX = getToString(config.getInitParameter("fixSuffix"), "");
isCheckParam = getToBoolean(config.getInitParameter("checkParam"), false);
if(CHECK_FIX.length() > 0)
{
CHECK_FIX = "," + CHECK_FIX + ",";
isCheckAllFix = false;
}
else
{
isCheckAllFix = true;
}
_timer = new Timer(true);
// Timer.schedule(TimerTask task, Date date, long period)// 從date開始,每period毫秒執行task.
_timer.schedule(_timerTask, 0, SYSTEM_REFRESH);// 從服務器啟動開始運行,每period毫秒執行
}
示例10: startVoiceTimeTask
import java.util.Timer; //導入方法依賴的package包/類
/**
* 錄音的時間控製
*/
public void startVoiceTimeTask(final Handler handler) {
voiceTimerLong = 0;
stopVoiceTimeTask();
voiceTimer = new Timer();
voiceTimerTask = new TimerTask() {
@Override
public void run() {
// 需要做的事:發送消息
sendVoiceTimeTask(handler);
}
};
// 500ms進行定時任務
voiceTimer.schedule(voiceTimerTask, 0, 500);
}
示例11: init
import java.util.Timer; //導入方法依賴的package包/類
public void init() throws ServletException{
TimerTask task = new TimerTask() {
@Override
public void run() {
System.out.println("task begin:" + getCurrentTime());
try {
//需要執行的任務
for (int i = 0; i < 10; i++) {
System.out.println("執行任務次數:"+i);
}
Thread.sleep(1000 * 20);//延遲20秒再執行下一步
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("task end:" + getCurrentTime());
}
};
Timer timer = new Timer();
timer.schedule(task, buildTime(), 1000 * 60 * 60 * 24);
}
示例12: openKeyboard
import java.util.Timer; //導入方法依賴的package包/類
private void openKeyboard() {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
}, 200);
}
示例13: onCreate
import java.util.Timer; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bnp = (NumberProgressBar)findViewById(R.id.numberbar1);
bnp.setOnProgressBarListener(this);
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
bnp.incrementProgressBy(1);
}
});
}
}, 1000, 100);
}
示例14: schedule
import java.util.Timer; //導入方法依賴的package包/類
private void schedule(Runnable r) {
TimerTask task = new TimerTask() {
public void run() {
r.run();
}
};
Timer timer = new Timer();
timer.schedule(task, (long) 5000, (long) 5000);
}
示例15: moviePlaying
import java.util.Timer; //導入方法依賴的package包/類
private void moviePlaying(ApplicationController app, MediaController media) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
media.stop( () -> stopApplication(app),errorLog);
}
}, PLAY_DURATION);
}