检测网络及启动画面

new Thread(new Runnable() {
            @Override
            public void run() {
                //记录线程开始时间
                long currentTime = System.currentTimeMillis();
                //请求网络
                //...省略代码
                //结束时间
                long stopTime = System.currentTimeMillis();
                
                //间隔时间
                long time = stopTime-currentTime;
                //间隔时间小于页面停留时间,则线程休眠,休眠时间=停留时间-已经执行代码的时间
                if (time<2000) {
                    try {
                        Thread.sleep(2000-time);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
原文地址:https://www.cnblogs.com/guduey/p/4397418.html