加载SDK时,MetaIO progressDialog会冻结

时间:2013-09-18 21:14:36

标签: java android augmented-reality

我是Android / Java的新手,我的第一个应用程序是使用MetaIO SDK。

我正在尝试实施“加载”进度条,而正在加载app(MetaIO SDK)。

  1. 显示叠加背景
  2. 出现加载对话框,“加载图片”开始旋转
  3. 叠加背景消失,加载图片停止旋转< - 问题
  4. 2-3秒后解冻并执行ARELViewActivity。
  5. 代码:

    public void onScanButtonClick(View v)
    {
      new ScanLoadingDialog().execute(0);
    }
    
    private class ScanLoadingDialog extends AsyncTask<Integer, Integer, Boolean>
    {
      //Before running code in separate thread
      @Override
    protected void onPreExecute()
    {
        progressDialog = new ProgressDialog(MainActivity.this);
        progressDialog.setMessage("Loading");
        progressDialog.setCancelable(false);
        progressDialog.setIndeterminate(false);
        progressDialog.show();
    }
    
    @Override
    protected Boolean doInBackground(Integer... params)
    {
      try
      {
        synchronized (this) {
          AssetsManager.extractAllAssets(getApplicationContext(), true);
          startActivity( new Intent(getApplicationContext(), ARELViewActivity.class));
        }
    
      }
      catch (IOException e)
      {
        MetaioDebug.log(Log.ERROR, "Error extracting assets: "+e.getMessage());
        MetaioDebug.printStackTrace(Log.ERROR, e);
        return false;
      }
    
      return true;
    }
    
    @Override
    protected void onPostExecute(Boolean result)
    {
      progressDialog.dismiss();
      finish();
    }
    

    }

    我做错了吗?

    P.S。完整的源代码可以在这里找到:link text P.S.S.与this question相关,但我使用的是那里建议的技术,但它仍然不想工作

1 个答案:

答案 0 :(得分:0)

我有类似的问题,我通过在UI线程上运行UI处理代码解决了这个问题

runOnUiThread(new Runnable() {
  @Override
  public void run() {
    if (imgvExampleOverlay != null) 
        imgvExampleOverlay.setVisibility(View.VISIBLE);
    }
  });

imgvExampleOverlay 是一个用户必须捕获的图像。

希望这有帮助

相关问题