views:

39

answers:

3

I have 2 Activities - A and B

In Activity A containing a list view spawns a new Sub-Activity B. In Acitivty B there is a button that launches Activity A so as to select another Sub-Activity B.

This seem to create an infinite loop scenario where

A->B->A->B->A->B->A->B->..............

So if i quit the program halfway, and the go back again will i get an issue?

because my programs has a exception thrown randomly that i have no solution to.

+1  A: 

What kind of exception does your program throw?

And no - this shouldn't be an issue as Android removes unused Activities from memory. The issue would happen if you would hold unused Activities in some variable fields and Android couldn't dispose them.

krtek
no i didn't do this. i suppose i am continuing debugging but the problem is so random and happens in different activity that its difficult to catch.
Kyith
Try using some error report library - http://code.google.com/p/acra/
krtek
+2  A: 

Without seeing the stack trace we really can't help you. This sounds like it's a really bad design patter though. You should take a look at the different launch modes

http://developer.android.com/guide/topics/fundamentals.html#lmodes

Falmarri
thanks. i resolve this issue. not really sure why. the most likely thing is that i change alot of static variables to non-static to resolve it.
Kyith
A: 

i did more debuggin and manage to find out that the error was caused by listviews with the error: "java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification....."

what is the most common cause of this.

I am using an async task to load my data and then set it to an adapter.

m_adapter is an adapter that stores more arrayadapters.(seperator pattern)

enter code here
//inner class
    private class GetTasks extends AsyncTask<Void,Void,Void>{
        private final ProgressDialog m_ProgressDialog = new ProgressDialog(PerspectiveTasks.this);

        @Override
        protected void onPreExecute(){
            this.m_ProgressDialog.setTitle("Get Tasks");
            this.m_ProgressDialog.setMessage("Retrieving Tasks. Please be patient...");
            this.m_ProgressDialog.show();
        }

        @Override
        protected Void doInBackground(Void... arg0) {
            m_adapter.sections.clear();
            m_adapter.headers.clear();

            try{


                        m_tasks = TaskInTasklist.getTasksInList(PerspectiveTasks.this, parent_id,PerspectiveTasks.task_filter,Global.DUE_OVERDUE,null,null).getTasks();
                        if(m_tasks.size()>0){
                            TaskAdapter taOverDue = new TaskAdapter(PerspectiveTasks.this, R.layout.row_task_item_1,m_tasks,parent_state);
                            m_adapter.addSection("Overdue", taOverDue);
                        }


            }catch(Exception e){
                Toast.makeText(PerspectiveTasks.this,e.getMessage(), Toast.LENGTH_LONG).show();
            }

            return null;
        }

        @Override
        protected void onPostExecute(final Void unused){

            try{
                ListView li = (ListView) findViewById(R.id.perspective_tasks_task_list);

                li.setAdapter(m_adapter);
                m_adapter.notifyDataSetChanged();
                this.m_ProgressDialog.dismiss();
            }catch(Exception e){
                Toast.makeText(PerspectiveTasks.this,e.getMessage(), Toast.LENGTH_LONG).show();
            }


        }
    }
Kyith