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. How to Set the Wall Paper Programatically in android?

All you have to do is call setWallpaper(), you do not need to
broadcast any intent, this will be done for you.






-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

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

2. AsyncTask Misbehaviours

hi, the code below was designed to display text within android (this
is a response from the web server). But somehow the code doesn't work-
looking at it I don't see any problem, and there are no errors
reported. The application runs and no code is displayed.

Can somebody with greater experience uncover any problem within the
program?

package http.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

 public class TestHttpClient extends Activity
 {
         @Override
                public void onCreate(Bundle icicle){
                        super.onCreate(icicle);
                        setContentView(R.layout.main);
                        new HttpConnect1().execute();
        }

         private class HttpConnect1 extends AsyncTask<String, Void, Void>
         {
                String result;
                @Override
                protected Void doInBackground(String...strings)
                {
                        BufferedReader in = null;
                        try {
                                HttpClient client = new DefaultHttpClient();
                                HttpPost request = new 
HttpPost("http://www.cnn.com");
                                List<NameValuePair> postParameters = new 
ArrayList<NameValuePair>
();
                                postParameters.add(new BasicNameValuePair("one",
"valueGoesHere"));
                                UrlEncodedFormEntity formEntity = null;
                                try {
                                        formEntity = new 
UrlEncodedFormEntity(postParameters);
                                } catch (UnsupportedEncodingException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                                request.setEntity(formEntity);
                                HttpResponse response = client.execute(request);
                                in = new BufferedReader(new 
InputStreamReader(response.getEntity
().getContent()));
                                StringBuffer sb = new StringBuffer("");
                                String line = "";
                                String NL = 
System.getProperty("line.separator");
                                while ((line = in.readLine()) != null) {
                                        sb.append(line + NL);
                                }
                                in.close();
                                result = sb.toString();

                        } catch (Exception e) {
                                e.printStackTrace();
                        } finally
                        {
                                if (in != null) {
                                try {
                                        in.close();
                                } catch (IOException e) {
                                        e.printStackTrace();
                                        }
                                }
                        }
                        return null;
                }
                //@Override
                protected void onPostExecute(String result)
                {
                    TextView tv = new TextView(TestHttpClient.this);
                    tv.setText(result);
                }
        }

}
--~--~---------~--~----~------------~-------~--~----~

3. location of wifi firmware files

4. TabHost + ListView + SMS == bug?

5. A question regarding the MotionEvent

6. Using ANT not Eclipse, How do I add a 3rd party jar

7. Android -- Build System guide and Source Tree organiziation