【问题标题】:Advice on how to fix frame skipping in android关于如何修复android中的跳帧的建议
【发布时间】:2013-10-22 20:43:20
【问题描述】:

所以我刚刚注意到我的应用在模拟器中运行时跳过了很多帧。这是我的第一个应用程序,我对该主题进行了一些阅读,发现我可能没有正确启动活动。但是,我的活动是通过设置菜单加载的,我不知道它在我的代码中的什么位置。如果这是一个大问题,如果有人能指出我与我的特定代码相关的正确方向,我将不胜感激? https://github.com/addrum/Calculate

如果需要,我可以优先在此处发布代码。

编辑:它似乎跳过了启动活动的帧:

package com.main.androidcalculator;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class SplashActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    Thread timer = new Thread() {
        public void run() {
            try{
                sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                Intent openMain = new Intent("com.main.androidcalculator.MAINACTIVITY");
                startActivity(openMain);
            }
        }
    };
    timer.start();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    finish();
}

}

【问题讨论】:

  • 我认为你应该写一段与你的问题相关的代码,因为人们很懒。
  • 在什么活动上跳过一些帧?
  • 你所有的活动看起来都很好。
  • “跳帧”是什么意思?视频帧数?你的启动活动中没有关于视频的任何内容,所以我假设不是它......
  • 在 Eclipse 中的 LogCat 中,我收到以下消息:10-22 21:27:57.495: I/Choreographer(2243): Skipped 74 帧!应用程序可能在其主线程上做了太多工作。我还注意到在 main 和 settings/about/help 活动之间来回切换时我得到了它。

标签: java android android-activity


【解决方案1】:

我认为模拟器太慢了。 您的代码在真实设备上运行良好。我在GS3上测试过。 也许ProgressBar 对模拟器来说太重了。 视图有动画和很多东西。 (删除 ProgressBar,问题就消失了!)

另请参阅: Choreographer(639): Skipped 50 frames

【讨论】:

  • 或者图像资源太大了:简单地显示六个 300kB 的 PNG 文件可能会在 Android 上引入 20 秒的延迟。您所看到的只是白屏和跳帧警告。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-19
  • 1970-01-01
  • 2019-06-04
  • 1970-01-01
  • 1970-01-01
  • 2011-10-28
相关资源
最近更新 更多