 new Thread(new Runnable() {             public void run() {                 try {                        Thread.sleep(0000);                   MainActivity.this.runOnUiThread(new Runnable() {                         @Override                         public void run() {                                      // update the main content by replacing fragments    Fragment fragment = null;    switch (thePos) {    /*case 0:     fragment = new  HomeFragment();     break;*/    case 0:     fragment = new  HomeFragment();     break;    case 0:     fragment = new  CalendarioFragment();     break;    case 0:     fragment = new  ContactoFragment();     break;    case 0:     fragment = new  OnclickFragment();     break;    default:     break;    }      if (fragment != null) {     try{     FragmentManager fragmentManager = getFragmentManager();     fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();       // update selected item and tit|le, then close the drawer     mDrawerList.setItemChecked(thePos, true);     mDrawerList.setSelection(thePos);     setTitle(navMenuTitles[thePos]);     mDrawerLayout.closeDrawer(mDrawerList);     }     catch(Exception E)     {      Log.e("MainActivity", "Error in creating fragment");     }    }     else {     // error in creating fragment     Log.e("MainActivity", "Error in creating fragment");    }   }});                 }                                       catch (Throwable t) {                 // just end the background thread                 Log.i("Animation", "Thread  exception " + t);             