简体   繁体   English

Android animation 在启动时导致“历史记录的活动空闲超时”

[英]Android animation causing “Activity idle timeout for History Record” on start up

I have been searching for an answer to this and while I can find others who have been seeing the same entries in the log cat none of the footprints seem to be similar to mine.我一直在寻找这个问题的答案,虽然我可以找到其他在日志猫中看到相同条目的人,但似乎没有一个脚印与我的相似。

Basically I start an infinitely repeating animation as part of my activity start up.基本上,作为我的活动启动的一部分,我开始无限重复 animation。 The screen is rendered properly, is responsive to all touch input but I get the following entries in my logcat:屏幕正确呈现,响应所有触摸输入,但我在我的 logcat 中得到以下条目:

08-17 16:03:25.910: WARN/ActivityManager(110): Launch timeout has expired, giving up wake lock: 08-17 16:03.25:972: WARN/ActivityManager(110). 08-17 16:03:25.910:WARN/ActivityManager(110):启动超时已过期,放弃唤醒锁:08-17 16:03.25:972:WARN/ActivityManager(110)。 Activity idle timeout for HistoryRecord{4057ad58 com.companyname.dm/.ui.activities.home.HomeActivity} HistoryRecord 的活动空闲超时{4057ad58 com.companyname.dm/.ui.activities.home.HomeActivity}

I have read posts that state these entries are indeed just warnings to indicate the main thread looper has never become idle and not a problem if it is the intended mode of operation.我读过帖子 state 这些条目确实只是警告,表明主线程循环器从未空闲,如果它是预期的操作模式,则不是问题。 However, besides that fact that it seems excessive that the small repeating animation (a scale/transform/alpha animation that repeats every 3 seconds) is filling the message queue, my main issue is that it is preventing the ability to create automated tests.但是,除了小重复 animation(每 3 秒重复一次的缩放/变换/alpha animation)填充消息队列似乎过度的事实之外,我的主要问题是它阻止了创建自动化测试的能力。 We are trying to implement a test using robotium but the test will never start because of the idle timeout.我们正在尝试使用 robotsium 实现测试,但由于空闲超时,测试永远不会开始。

Not starting the animation will eliminate this problem, but is much more a workaround than a root cause solution.不启动 animation 将消除此问题,但与其说是根本原因解决方案,不如说是一种解决方法。 I am trying to understand if I am either not implementing my animations properly, if this is indeed just the expected behavior or if there is a way to ensure the connection the instrumentation/robotium will be established.我试图了解我是否没有正确实现我的动画,这是否确实只是预期的行为,或者是否有办法确保建立仪器/机器人的连接。

Any insight would be greatly appreciated.任何见解将不胜感激。 Thanks.谢谢。

Try starting your animation in a new thread, if you do too much stuff in the onCreate method you will block the UI-thread in Android, and it could possibly lead to an ANR (Application not responding) if you take longer than 5 seconds before returning.尝试在新线程中启动 animation,如果您在 onCreate 方法中执行的操作过多,您将阻塞 Android 中的 UI 线程,如果您在 5 秒之前花费超过 5 秒,可能会导致 ANR(应用程序无响应)返回。 By starting your animation in a new thread the onCreate will return and the system will be happy.通过在新线程中启动 animation,onCreate 将返回并且系统会很高兴。

new Thread(new Runnable() {
  public void run() {
    //start animation.
  }
}.start();

The code which is repainting to the screen need to be started in a different thread, else the main UI thread will never become idle, which is causing the problem.重新绘制到屏幕上的代码需要在不同的线程中启动,否则主 UI 线程将永远不会空闲,这会导致问题。

You may have issues when interacting with the UI from another thread, for this you should look into AsyncTask which is actually what is used to compute/draw progress bars.从另一个线程与 UI 交互时,您可能会遇到问题,为此您应该查看AsyncTask ,它实际上是用于计算/绘制进度条的。 The obscene number of warnings is most likely because the warnings are generated any time after X seconds, which is only limited by Android's checks.警告数量过多很可能是因为警告是在 X 秒后的任何时间生成的,这仅受 Android 的检查限制。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM