简体   繁体   English

我的android应用显示了一个视频,并且必须一直运行,但是几个小时后我的应用停止了

[英]My android app shows a video and must be always running, but after few hours my app is stopped

I'm new on android application and i'm creating an app that shows a video using a VideoView, I use a CountDownTimer to search each 15 seconds for video updates and play another video. 我是android应用程序的新手,正在创建一个使用VideoView显示视频的应用程序,我使用CountDownTimer每隔15秒搜索一次视频更新并播放另一个视频。 My app works very well during 2 or 3 hours but after this my app just stop, the application doesn't close but is stopped and I must close and open again. 我的应用程序在2到3个小时内可以很好地运行,但是在此之后我的应用程序刚刚停止运行,该应用程序没有关闭但已停止,我必须关闭并再次打开。 What should I do? 我该怎么办? Thanks. 谢谢。

It literally stops on the screen, it stops the timer and video view. 它实际上在屏幕上停止,它停止计时器和视频视图。 Here is the code that i'm using to count time to call functions to show video and time. 这是我用来计数时间以调用函数以显示视频和时间的代码。

new CountDownTimer(20000, 1000) {
             public void onTick(long millisUntilFinished) {

                time++;
                downloadTime++;
                if(downloadTime == 2){  // Should be executed each 2 seconds
                    DoDownloads();
                    downloadTime = 0; //
                }
                    showPlayer();
                    showTime();

             }

             public void onFinish() {
                 this.start();
             }
          }.start();

I can't show any log because this happens after some hours and can be 2 hours or 10 hours, and i'm testing on tablet. 我无法显示任何日志,因为这会在几个小时后发生,可能是2个小时或10个小时,我正在平板电脑上进行测试。

We would need the code of the rest of your functions, like DoDownloads(); showPlayer(); showTime(); 我们需要其余功能的代码,例如DoDownloads(); showPlayer(); showTime(); DoDownloads(); showPlayer(); showTime();

anyways, i wouldnt restart the countdown that way. 无论如何,我不会以这种方式重启倒计时。 Id try with a handler and postdelayed(Runnable), like: id尝试使用处理程序并延迟(Runnable),例如:

private Handler handler = new Handler();

private Runnable runnable = new Runnable() {
   @Override
   public void run() {
            time++;
            downloadTime++;
            if(downloadTime == 2){  // Should be executed each 2 seconds
                DoDownloads();
                downloadTime = 0; //
            }
                showPlayer();
                showTime();

     handler.postDelayed(this, tiempo);
   }
};

handler.postDelayed(runnable, tiempo); 

And also, you should debug the app and copy/past the log cast in the moment it fails, and give us some information about in what point the execution wsa 另外,您还应该调试该应用,并在发生故障的那一刻复制/粘贴日志,并向我们提供一些有关执行wsa的信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 毫无意义,我的 Android 应用停止运行了。? - For no reson my Android app stopped running.? 几个小时后,我的无尽后台服务自动停止。 为什么? - My Endless background Service Stopped Automatically After Few Hours . Why? 为什么我的带有 Hls.js 视频播放器的 Android Webview 应用程序在 3-4 小时后冻结? - Why does my Android Webview app with a Hls.js video player freezes after 3-4 hours? 不幸的是我的Android应用已停止 - Unfortunately my android app is stopped 运行应用程序后,我的应用程序不断收到“不幸的是,“我的应用程序”已停止” - my application keeps receiving “Unfortunately ”My App“ has stopped” after Running the app 当我打开我的 flutter 应用程序时,它总是显示登录屏幕几秒钟,即使我已经在上次会话中登录。 在那个主页之后? - When I open my flutter app it always shows Sign In screen for few seconds, even if I already signed In in my last session. And after that Main page? 从 Android Studio 在我的手机上运行的应用程序显示空白屏幕 - App running on my Phone from Android Studio shows blank screen Android应用程序停止运行 - android app is stopped running 不幸的是,我的应用已停止(我在android中的第一个应用) - unfortunately my app has stopped (my first app in android) 我的应用在我的Android智能手机上显示错误 - My app shows an error on my android smartphone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM