Progress Dialog on open activity

Posted by GeeXor on Stack Overflow See other posts from Stack Overflow or by GeeXor
Published on 2010-11-23T08:42:47Z Indexed on 2011/01/11 0:53 UTC
Read the original article Hit count: 137

Filed under:
|

hey guys, i've a problem with progress dialog on opening an activity (called activity 2 in example). The activity 2 has a lot of code to execute in this OnCreate event.

final ProgressDialog myProgressDialog = ProgressDialog.show(MyApp.this,getString(R.string.lstAppWait), getString(R.string.lstAppLoading), true);
new Thread() {
    public void run() {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showApps();
            }
        });
        myProgressDialog.dismiss();
    }
}.start(); 

The showApps function launch activity 2.

if i execute this code on my button click event on activity 1, i see the progress, but she doesn't move and afeter i have a black screen during 2 or 3 seconds the time for android to show the activity.

If i execute this code in the OnCreate of Activity2 and if i replace the showApps by the code on OnCreate, Activity1 freeze 2 seconds, i don't see the progress dialog, and freeze again 2 seconds on activity 2 before seeing the result.

An idea ?

© Stack Overflow or respective owner

Related posts about android

Related posts about progressdialog