ActivityGroup crash suddenly
===

I have tabview, in one of the tabbs I want to load many activities, one from one, and so on so I used Activitygroup like this :

    public class CtegoriesGroup extends ActivityGroup {
    
        // Keep this in a static variable to make it accessible for all the nesten activities, lets them manipulate the view
    public static CtegoriesGroup group;
    
        // Need to keep track of the history if you want the back-button to work properly, don't use this if your activities requires a lot of memory.
    private ArrayList<View> history;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          this.history = new ArrayList<View>();
          group = this;
    
              // Start the root activity withing the group and get its view
          View view = getLocalActivityManager().startActivity("Sections", new
        	      							Intent(this,Sections.class)
        	      							.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
        	                                .getDecorView();
    
              // Replace the view of this ActivityGroup
          replaceView(view);
    
       }
    
    public void replaceView(View v) {
                // Adds the old one to history
    	history.add(v);
                // Changes this Groups View to the new View.
    	setContentView(v);
    }
    
    public void back() {
    	if(history.size() > 0) {
    		history.remove(history.size()-1);
    		setContentView(history.get(history.size()-1));
    	}else {
    		finish();
    	}
    }
    
    @Override
    public void onBackPressed() {
    	CtegoriesGroup.group.back();
        return;
    }
    
    }

the Sections class look like 


    public class Sections  extends ListActivity {
    	
    	
    	 // Progress Dialog
        private ProgressDialog pDialog;
    	
    	// THE XML MAIN inputs
    	// The XML InputData
    	static final String URL = "http://zindicate.com/app000/categories.php";
    	// XML node keys
    	static final String KEY_ITEM = "category"; // parent node
    	static final String KEY_imageUrl = "imageUrl";
    	static final String KEY_name = "name";
    	static final String KEY_feedUrl = "feedUrl";
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.sectionsview);
     
            
            ////////////////////////////////////////////////////////////
            
            //list
            
            
            
            
            
            
            
            ////////////////////////////////////////////////
           
            GlobalVariables appState = (GlobalVariables) Sections.this.getApplication();
    			appState.MainCategories = new ArrayList<HashMap<String, String>>();
    			
            // Loading INBOX in Background Thread
            new LoadSections().execute();
        }
        
       
        @Override
        protected void onListItemClick(ListView l, View v, int position, long id) {
        	 
        	GlobalVariables appState = (GlobalVariables) Sections.this.getApplication();
        	// create Intent and set LoginSuccess Activity
        	
        	if(appState.MainCategories != null)
        		Log.d("sfsfwqjfwjfwq",appState.MainCategories.get(position).get("feedUrl"));
        	else
        		Log.d("sfsfwqjfwjfwq","teeeeeeeeeeeeeeeeeeeeeeeet");
        
        	  Intent intent = new Intent(getApplicationContext(),
        	
        			  SectionContentList.class);
        	
        	  // put values to intent which will get in the LoginSuccess    Activity
        	 
        	 Log.d("",appState.MainCategories.get(position).get("feedUrl"));
    			
        	  intent.putExtra("FeedURL", appState.MainCategories.get(position).get("feedUrl"));
        	
        	  // Start LoginSuccess Activity
        	
        	  startActivity(intent);
    
        	
        	
        }
    
        class LoadSections extends AsyncTask<String, String, String> {
        	 
            /**
             * Before starting background thread Show Progress Dialog
             * */
            @Override
            protected void onPreExecute() {
                super.onPreExecute();
                pDialog = new ProgressDialog(Sections.this);
                pDialog.setMessage("Loading Categories ...");
                pDialog.setIndeterminate(false);
                pDialog.setCancelable(false);
                pDialog.show();
            }
     
            /**
             * getting Inbox JSON
             * */
            protected String doInBackground(String... args) {
    
            	// TODO Auto-generated method stub
        		
        		Log.d("I am here "," MyPagerAdapter");
        		
                // Hashmap for ListView
                GlobalVariables appState = (GlobalVariables) Sections.this.getApplication();
        			
        			
    
        		XMLParser parser = new XMLParser();
        		
        		
        		String xml = parser.getXmlFromUrl(URL); // getting XML
        		Log.d("getXmlFromUrl" , "Done");
        		
        		Log.d("xml",xml);
        		
        		Document doc = parser.getDomElement(xml); // getting DOM element
        		Log.d("getDomElement" , "Done");
    
        		NodeList nl = doc.getElementsByTagName(KEY_ITEM);
        		
        		Log.d("getElementsByTagName" , "Done");
        		
        		
        		// looping through all item nodes <item>
        		for (int i = 0; i < nl.getLength(); i++) {
        			// creating new HashMap
        			HashMap<String, String> map = new HashMap<String, String>();
        			Element e = (Element) nl.item(i);
        			// adding each child node to HashMap key => value
        			map.put(KEY_imageUrl, parser.getValue(e, KEY_imageUrl));
        			map.put(KEY_name, parser.getValue(e, KEY_name));
        			map.put(KEY_feedUrl, parser.getValue(e, KEY_feedUrl));
    
        			// adding HashList to ArrayList
        			appState.MainCategories.add(map);
        			
        			Log.d("I am here "," MyPagerAdapter2");
        			Log.d("The length is", ""+appState.MainCategories.size());
        			
        			
        		}
                return null;
            }
     
            /**
             * After completing background task Dismiss the progress dialog
             * **/
            protected void onPostExecute(String file_url) {
                // dismiss the dialog after getting all products
                pDialog.dismiss();
                // updating UI from Background Thread
                runOnUiThread(new Runnable() {
                    public void run() {
                        /**
                         * Updating parsed JSON data into ListView
                         * */
                        GlobalVariables appState = (GlobalVariables) Sections.this.getApplication();
            			
            			
                    	SectionsAdapter adapter = new SectionsAdapter(Sections.this ,R.layout.sectionviewgridview,
                    			appState.MainCategories);
                        // updating listview
                        setListAdapter(adapter);
                    }
                });
     
            }
        }
        
        
    	
    
    	
    
    }

but when run the code I got this error 


    07-15 04:02:19.047: E/AndroidRuntime(563): FATAL EXCEPTION: main
    07-15 04:02:19.047: E/AndroidRuntime(563): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Zindicate/com.Zindicate.ZindicateActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Zindicate/com.Zindicate.CtegoriesGroup}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Zindicate/com.Zindicate.Sections}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44f72060 is not valid; is your activity running?
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.os.Looper.loop(Looper.java:123)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.main(ActivityThread.java:4627)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at java.lang.reflect.Method.invokeNative(Native Method)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at java.lang.reflect.Method.invoke(Method.java:521)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at dalvik.system.NativeStart.main(Native Method)
    07-15 04:02:19.047: E/AndroidRuntime(563): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Zindicate/com.Zindicate.CtegoriesGroup}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Zindicate/com.Zindicate.Sections}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44f72060 is not valid; is your activity running?
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.widget.TabHost.setCurrentTab(TabHost.java:323)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at com.Zindicate.ZindicateActivity.onCreate(ZindicateActivity.java:34)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	... 11 more
    07-15 04:02:19.047: E/AndroidRuntime(563): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Zindicate/com.Zindicate.Sections}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44f72060 is not valid; is your activity running?
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at com.Zindicate.CtegoriesGroup.onCreate(CtegoriesGroup.java:25)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	... 19 more
    07-15 04:02:19.047: E/AndroidRuntime(563): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44f72060 is not valid; is your activity running?
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.view.ViewRoot.setView(ViewRoot.java:505)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.view.Window$LocalWindowManager.addView(Window.java:424)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.Dialog.show(Dialog.java:241)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at com.Zindicate.Sections$LoadSections.onPreExecute(Sections.java:110)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.os.AsyncTask.execute(AsyncTask.java:391)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at com.Zindicate.Sections.onCreate(Sections.java:65)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    07-15 04:02:19.047: E/AndroidRuntime(563): 	at android.app.ActivityThread.performLaunchAct

