1

我试图等到spalsh屏幕结束,然后当从splash获得结果时转到另一个活动但我的代码不等待splash(AsyncTask)只是为了之后的意图。希望你能帮忙。

 lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

            String nextActivity=new String();
            Thread splashTread = new Thread() {
                @Override
                public void run() {
                    try {
                        splash  splash=(tools.splash) new splash(first.this).execute();
                        int waited = 0;
                        while(splash.running && (waited< getResources().getInteger(R.integer.splashTimeOut)))
                        {
                            sleep(100);
                            if(splash.running) {
                                waited += 100;
                            }
                            // nextActivity=splash.newActivity;
                        }
                        Intent intent = new Intent(first.this,Class.forName("activities.third"));
                     startActivity(intent);
                    } catch(InterruptedException e) {
                        // do nothing
                    } catch (ClassNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } finally {
                        finish();

                    }
                }
            };
            splashTread.start();


            try {
                Intent intent = new Intent(first.this,Class.forName("activities.third"));
                 startActivity(intent);
4

1 回答 1

0

使用此代码

 Intent intent = new Intent(first.this,Class.forName("activities.third"));
                 startActivity(intent);

finally之前finish()而不是开始尝试块内;

于 2012-09-26T09:49:14.727 回答