Search code examples
androidlayoutandroid-asynctaskload-order

Android displaying white screen until Asynctask starts but I have already loaded a layout


So I have the following code and a problem: It should load a layout that should say "downloading database..." (dynamically added to the layout) however I get a white-screen until the database is updated and then it just proceeds with add_categories_layout(0) and works fine.

How do I get it to show me the first layout?

protected void onResume(){

    super.onResume();
    setContentView(R.layout.home_screen_layout);
    SF = (LinearLayout) findViewById(R.id.SF);
    p_db_adapter = new DBAdapterProducts(getApplicationContext());
    c_db_adapter = new DBAdapterCategories(getApplicationContext());
    add_downloading_DB_layout();

    new UpdateDB().execute(CATEGORY_URL, PRODUCTS_URL, TIMESTAMP_URL_CATEGORIES, TIMESTAMP_URL_PRODUCTS);       
    while(DBupdated == false){}
    add_categories_layout(0);

}


Solution

  • It won't draw the screen until onResume has finished, and onResume won't finish until DBUpdated is true (at which point the layouts are swapped).