2

我在不同的设备上使用 ObjectAnimator 和测试应用程序。在一些缓慢的旧手机上,它的动画效果太差了(没有 GPU,没有内存等),所以我想自动将用户切换到应用程序的第二个(精简版)版本。

那么如何慢慢检测ObjectAnimator是什么东西呢?

  1. 它有一些帧率报告吗?我什么也没找到。
  2. 编舞者是否有相同的听众?它列出了 catlog 中的错误,但我想在代码中获取它。

    01-22 05:55:15.775:信息/编舞(3794):跳过 33 帧!应用程序可能在其主线程上做了太多工作。

注意:我知道如何通过系统命令解析 catlog,但在我看来这不是一个聪明或快速的解决方案。

注2:我不需要让事情变得更快。我需要检测慢速电话。

4

1 回答 1

0

好的,这个解决方案工作正常

它可以从 ObjAnimator 的循环中调用(例如监听器 - onRepeat)

您可以统计事件并得出有关设备速度的结论。

ps 它不够聪明,但直到没有人回答本机帧率报告...

boolean getCatLog(){
    boolean yes=false;
    try {
        Process process = Runtime.getRuntime().exec("logcat -d");
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String output;
        String lastLine = null;
        while ((output = reader.readLine()) != null) {
            lastLine = output;
        }
        if(lastLine!=null && lastLine.contains("Choreographer")){
            Log.d(TAG,"yes!");  //do not remove!
            yes=true;
        }
        reader.close();
        process.waitFor();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    return yes;
}
于 2014-05-27T18:39:56.697 回答