[英]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.