0

加载数据后,我正在尝试启动新意图。我正在使用一个处理程序,它在线程完成时调用一个方法,然后在这个方法中我试图启动一个新的 Intent,但我的应用程序每次都崩溃。我已将其范围缩小到 Intent 构造函数中的 Context 变量。这是我的代码:

/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        pDialog = new ProgressDialog(this);

        pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        pDialog.setMessage("Loading...");
        pDialog.setCancelable(false);
        pDialog.show();

        mHandler = new Handler();
        checkUpdate.start();
    }

    private Thread checkUpdate = new Thread()
    {
     public void run()
     {
      try
      {
                        //Do some stuff

          mHandler.post(showUpdate);
      }
      catch(Exception e)
      {
       //Error case
      }
     }
    };

    private final Context context = this;        

    private Runnable showUpdate = new Runnable()
    {
     public void run()
     {
      //Do post process

      pDialog.dismiss();

                    //This is the line it crashes on
      Intent intent = new Intent(context, com.example.example1.TestListActivity.class);
         startActivityForResult(intent, 0);
     }
    };
4

1 回答 1

1

我想到了。结果我忘了在清单文件中包含新的活动。

于 2010-09-30T17:40:10.920 回答