从涂黑屏幕preventing视频下载 [英] Preventing Thread.sleep from blacking out screen

查看:114
本文介绍了从涂黑屏幕preventing视频下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的加载的布局开始之前,我的视频后,创建插入一个暂停。

I want to insert a pause in my create after loading the layout before I start a video.

布局加载,我想显示3秒开始之前,我的视频图像。

The layout loads an image which I want to display for 3 seconds before I start a video.

这是我试过什么(这code是在的onCreate 法)

This is what I've tried (this code is in the onCreate method)

      setContentView(R.layout.layout_name);
      try {
          Thread.sleep(3000);
      } catch ...
           ...
      }
      startVideo();

问题是,调用视频下载黑人显示,然后将视频开始。

The problem is that calling Thread.sleep blacks the display and then the video starts.

我怎样才能使画面不走黑?

How can I make the screen not go black?

推荐答案

你挡住了UIThread那是什么原因造成它去空白...
更换你的尝试用以下{...} 块:

You're blocking the UIThread thats what is causing it to go blank... Replace your try {...} block with the following:

new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            startVideo();
        }
    }, 3000);

和考虑把,在在onStart onResume ...

And consider putting that in the onStart or onResume...

您也应该阅读进程和线程以获得什么运行在哪里,并知道在哪里可以阻止并在那里你不能......

You should also read Processes and Threads to get an idea of what runs where and where you can block and where you cannot...

这篇关于从涂黑屏幕preventing视频下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆