【问题标题】:Choreographer: Skipped 127 frames! The application may be doing too much work on its main thread编舞:跳过127帧!应用程序可能在其主线程上做了太多工作
【发布时间】:2014-10-25 18:05:01
【问题描述】:

我正在尝试将图像显示 7 秒并将其隐藏。但是当我运行我的应用程序时,它显示跳过了 127 帧,应用程序可能在其主线程上做了太多工作。如何消除此错误?这是我的代码 // 版权所有 2007-2014 metaio GmbH。版权所有。 包 com.donseenu.two;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.metaio.sdk.ARViewActivity;
import com.metaio.sdk.MetaioDebug;
 import com.metaio.sdk.jni.IGeometry;
import com.metaio.sdk.jni.IMetaioSDKCallback;
import com.metaio.tools.io.AssetsManager;


public class Template extends ARViewActivity 
{

@Override
protected int getGUILayout() 
{
    // Attaching layout to the activity



    return R.layout.tutorial_hello_world; 
}


public void onButtonClick(View v)
{
    finish();
}







@Override
protected void loadContents() 
{


     this.runOnUiThread(new Runnable() {
            @Override
            public void run() {


                    try{
                      Thread.sleep(7000);
                    }
                    catch(Exception e)
                    {
                    }



                    ImageView image = (ImageView)findViewById(R.id.remove);
                image.setVisibility(View.GONE);

            }
        });






    try
    {
        // Getting a file path for tracking configuration XML file
        String trackingConfigFile = AssetsManager.getAssetPath(getApplicationContext(), "TrackingData_MarkerlessFast.xml");

        // Assigning tracking configuration
        boolean result = metaioSDK.setTrackingConfiguration(trackingConfigFile); 
        MetaioDebug.log("Tracking data loaded: " + result); 

        // Getting a file path for a 3D geometry
        String metaioManModel = AssetsManager.getAssetPath(getApplicationContext(), "augmented_city.obj");          
        if (metaioManModel != null) 
        {
            // Loading 3D geometry
            IGeometry geometry = metaioSDK.createGeometry(metaioManModel);
            if (geometry != null) 
            {
                // Set geometry properties
                geometry.setScale(4f);
            }
            else
                MetaioDebug.log(Log.ERROR, "Error loading geometry: "+metaioManModel);
        }


    }
    catch (Exception e)
    {
        MetaioDebug.printStackTrace(Log.ERROR, e);
    }
}


@Override
protected void onGeometryTouched(IGeometry geometry)
{
    // Not used in this tutorial
}


@Override
protected IMetaioSDKCallback getMetaioSDKCallbackHandler()
{
    // No callbacks needed in this tutorial
    return null;
}   
}

【问题讨论】:

    标签: android multithreading


    【解决方案1】:

    不要在 UI 线程上休眠。在此期间,UI 无法重绘帧,因此系统正确地告诉您它们正在被跳过。

    如果您想在未来几秒钟内安排某事,请使用 Handler 之类的内容

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多