當前位置: 首頁>>代碼示例>>Java>>正文


Java Timer.schedule方法代碼示例

本文整理匯總了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());
}
 
開發者ID:theopenbit,項目名稱:yaacc-code,代碼行數:18,代碼來源:LocalBackgoundMusicPlayer.java

示例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);
}
 
開發者ID:cdc03819,項目名稱:BrewBook,代碼行數:17,代碼來源:Splash.java

示例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);
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:25,代碼來源:InitStartActivity.java

示例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);

}
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:17,代碼來源:AlarmHttpAppender.java

示例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);



}
 
開發者ID:LeeDJD,項目名稱:Amme,代碼行數:20,代碼來源:Stats.java

示例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);
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:23,代碼來源:HydrographEngineCommunicatorSocket.java

示例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,代表三秒
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:24,代碼來源:LoadingActivity.java

示例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);
}
 
開發者ID:ajtdnyy,項目名稱:ScreenCut,代碼行數:19,代碼來源:ScreenCut.java

示例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毫秒執行
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:22,代碼來源:AuthFilter.java

示例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);

}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:19,代碼來源:SobotBaseActivity.java

示例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);
}
 
開發者ID:LuJiangLin,項目名稱:TestDemo1-github,代碼行數:25,代碼來源:TestThread.java

示例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);
    }
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:13,代碼來源:WatchLiveActivity.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:MrChebik,項目名稱:Coconut-IDE,代碼行數:10,代碼來源:SaveTabsProcess.java

示例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);
}
 
開發者ID:Orange-OpenSource,項目名稱:OCast-Java,代碼行數:10,代碼來源:App.java


注:本文中的java.util.Timer.schedule方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。