IllegalStateException: Fragment not added in ActionBarTabs example

by Ed Burnette » Fri, 20 May 2011 02:29:06 GMT


Sponsored Links
 While writing an app that uses Fragments and tabs on the Action Bar I
ran into a crash. I went back to the API Demos sample and can make the
same crash happen there. Start the program in the emulator and select
App > Action Bar > Action Bar Tabs. Click "Toggle tab mode" then "Add
new tab" twice, then click back and forth between the two tabs very
quickly until it crashes. Here's the traceback:


05-19 18:16:06.668: ERROR/AndroidRuntime(1153): FATAL EXCEPTION: main
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):
java.lang.IllegalStateException: Fragment not added:
TabContentFragment{407c55a8 #0 id=0x7f08000c Tab 1}
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
android.app.BackStackRecord.remove(BackStackRecord.java:366)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
com.example.android.apis.app.ActionBarTabs
$TabListener.onTabUnselected(ActionBarTabs.java:94)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
com.android.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:
476)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
com.android.internal.app.ActionBarImpl
$TabImpl.select(ActionBarImpl.java:816)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
com.android.internal.widget.ActionBarView
$TabClickListener.onClick(ActionBarView.java:954)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
android.view.View.performClick(View.java:3110)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
android.view.View$PerformClick.run(View.java:11928)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
android.os.Handler.handleCallback(Handler.java:587)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
android.os.Handler.dispatchMessage(Handler.java:92)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
android.os.Looper.loop(Looper.java:132)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
android.app.ActivityThread.main(ActivityThread.java:4025)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
java.lang.reflect.Method.invokeNative(Native Method)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
java.lang.reflect.Method.invoke(Method.java:491)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-19 18:16:06.668: ERROR/AndroidRuntime(1153):     at
dalvik.system.NativeStart.main(Native Method)
05-19 18:16:06.698: WARN/ActivityManager(82):   Force finishing
activity com.example.android.apis/.app.ActionBarTabs

Is this a known problem? I tried it under SDK Platform 3.0 (rev 1) and
3.1 (rev 2).

-- 



Re: IllegalStateException: Fragment not added in ActionBarTabs example

by Shane Isbell » Fri, 20 May 2011 02:46:46 GMT


 I've run into this on occasion, I surrounded it with a general Exception
catch to handle this, which seemed to have no side affects for my
application, as to whether this is platform bug, who knows? Without the
source code to look at, it is anyone's guess.

Shane





-- 


Sponsored Links


Other Threads

1. Touch Event

Hi
I have some problem in Touch Event
In my screen I am using one Scrollview. Inside this ScrollView i have
taken one Absoulte Layout and in this Layout i am dragging the
component. the Problem is i am not able to drag component below the
Physical screen. component is not moving below the physical screen. i
dont understand wt is the problem.

My code is for Touch Event

  row.setOnTouchListener(new OnTouchListener(){

                                @Override
                                public boolean onTouch(View view, MotionEvent 
event) {


                                        int eventaction = event.getAction();
                                        int y = (int) event.getRawY();



                                        int rowNo = 
Integer.parseInt(indexid1.getText().toString());
                                        int catId = 
Integer.parseInt(RowID.getText().toString());

                                         switch (eventaction) {

                                                case
MotionEvent.ACTION_DOWN:

                                                case MotionEvent.ACTION_MOVE:
                                                // Moving the Item

                                                        view.bringToFront();
                                                        
AbsoluteLayout.LayoutParams R =
                                                                   new 
AbsoluteLayout.LayoutParams
                                                                          ( 
AbsoluteLayout.LayoutParams.FILL_PARENT,
AbsoluteLayout.LayoutParams.WRAP_CONTENT,0,y-110);
                                                                
view.setLayoutParams(R);

                                                break;

                                                case MotionEvent.ACTION_UP:

                                                        // Setting the Changed 
row position




                                                break;
                                                default :
                                                        break;





                so plz someone try to help me.


Thanks







--~--~---------~--~----~------------~-------~--~----~

2. ListView/Adapter Crash in 1.6 only: illegalStateException. 1.6 bug?

Romain,

thanks for confirming that this message is new in 1.6.

Actually, I mean to write "I'm sure my adapter mods are IN the UI
thread, not the background thread". Anything else that can cause this?

If I step through the code in the de{*filter*} I don't get the exception,
but I I run without stepping I do. Also, when I run the phone on
the app, I can get it to "work" 3 or 4 times, and then eventually I'll
get the force close.

Can anything else cause this?

Here's my code in the background thread:

        public void run(){
                int i = 0;
                lsDb.openDataBase();
                rescursor = lsDb.Search();
                if (rescursor.getCount() > 0){
                    id_index = rescursor.getColumnIndex("_id");
                    name_index = rescursor.getColumnIndex("Name");
                    calories_index = rescursor.getColumnIndex("Calories");
                    extra_index = rescursor.getColumnIndex("sodium");
                }
                if (rescursor.moveToFirst()){
                        do {
                                int id = rescursor.getInt(id_index);
                                String name = rescursor.getString(name_index);
                                int calories = rescursor.getInt(calories_index);
                                double extra= rescursor.getDouble(extra_index);
                                                                // add
to array list
                                myArrayList.add(i, new CalStats(name, extra, 
calories));
                                i++;
                                }
                        while (rescursor.moveToNext());
                }
                rescursor.close();
                lsDb.close();
                hh.post(postdoSearchDatabase);
        }

The "post" at the end is to a handler. I **do** modify the adapter in
the run method there.





--~--~---------~--~----~------------~-------~--~----~

3. ListView/Adapter Crash in 1.6 only: illegalStateException. 1.6 bug?

4. Setting proxy on emulator: Unable to open settings.db

5. Establishing WiFi connection to a chosen hotspot

6. Setting proxy on emulator: Unable to open settings.db

7. confused about service