1

我的应用程序速度有问题。
我的应用程序使用带有计时器的处理程序,该计时器计算屏幕上显示的不同对象的坐标并使简单视图无效。它在启动时运行良好,但开始运行需要 3 或 4 秒,并且 logcat 经常打印“跳帧”。我对线程的理解不是很好,所以我认为问题来自这里。
如果您能看看我的问题,我将不胜感激:)

这是我正在谈论的代码:

public void resume() {
    keepGoing = true;

    moveFlag = false;

    final Timer timer = new Timer();
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            mHandler.post(new Runnable() {
                @Override
                public void run() {

                    // ARRET DU CHRONOMETRE
                    if (!keepGoing){
                        cancel();
                    }

                    // MOVING OF THE OBJECTS

                    // REFRESHING THE VIEW
                    mView.invalidate();
                }
            });
        }
    }, 0, Interval);
}

非常感谢 !!

编辑:这是我开始活动时的 logcat 结果:

09-23 21:20:08.893 16382-16382/com.example.myapplication D/ViewRootImpl: #1    mView = com.android.internal.policy.PhoneWindow$DecorView{760d030 I.E...... R.....ID 0,0-0,0}  
09-23 21:20:08.933 16382-16382/com.example.myapplication I/Choreographer: Skipped 75 frames!  The application may be doing too much work on its main thread.
09-23 21:20:08.973 16382-16382/com.example.myapplication W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
09-23 21:20:09.163 16382-16382/com.example.myapplication D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
09-23 21:20:09.213 16382-16382/com.example.myapplication I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@775d973 time:10307099
09-23 21:20:09.463 16382-16382/com.example.myapplication D/ViewRootImpl: #3 mView = null
4

0 回答 0