java - 为什么在我使用处理程序和简单视图时我的应用程序很慢?
问题描述
我的应用程序速度有问题。
我的应用程序使用带有计时器的处理程序,该计时器计算屏幕上显示的不同对象的坐标并使简单视图无效。它在启动时运行良好,但开始运行需要 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
解决方案
推荐阅读
- json - 在 React 中用 CSS 替换 JSON 值
- javascript - 在条件下将密钥转换为对?
- python - 当我在 Django 中迁移时获取不是有效的 UUID
- swagger - 除了使用“body”属性来使用 OpenAPI/Swagger 和“aws_api_gateway_rest_api”,还有其他选择吗?
- node.js - 如何通过与 Angular Web 应用程序相同的域访问 API
- ssl - 为什么谷歌管理的 SSL 证书需要域 DNS 指向静态 IP 地址而不是负载均衡器本身?
- javascript - Node.js - process.exit(-1)
- django - Django Rest Framework 使用具有不同渲染器的视图集
- python - 如何使用 Python 启用 Google Assistant API 的新“阅读”功能?
- qt - Qt:QPushButton 垂直大小,适合内容吗?