赞
踩
- //每6小时弹出請求网络策略
- ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
- scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- Log.e("ScheduledExecutor","ScheduledExecutor");
- if (Utils.isNetWorkAvaiable(SupportService.this)) {
- //执行操作
- }
- }
- },6,6,TimeUnit.HOURS);
* * @param command the task to execute * @param initialDelay the time to delay first execution * @param period the period between successive executions * @param unit the time unit of the initialDelay and period parameters * @return a ScheduledFuture representing pending completion of * the series of repeated tasks. The future's {@link * Future#get() get()} method will never return normally, * and will throw an exception upon task cancellation or * abnormal termination of a task execution. * @throws RejectedExecutionException if the task cannot be * scheduled for execution * @throws NullPointerException if command is null * @throws IllegalArgumentException if period less than or equal to zero */ public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。