I have a PreferenceActivity (TabTabHostPreferences) which is a tab in
TabActivity B (InnerTabActivity) which is a tab in TabActivity A
(TabTabPref). I admit its a bit convoluted but its design feels a
natural for my project.  I am getting the error, listed below, when I
try to open a EditTextPreference in my TabTabHostPreferences.  The
error occurs before the dialog appears. I have also included my
TabActivites for completeness.


12-23 11:36:59.630: ERROR/AndroidRuntime(816): FATAL EXCEPTION: main
12-23 11:36:59.630: ERROR/AndroidRuntime(816):
android.view.WindowManager$BadTokenException: Unable to add window --
token android.app.localactivitymanager$localactivityrec...@44ef7610 is
not valid; is your activity running?
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.view.ViewRoot.setView(ViewRoot.java:505)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.view.Window$LocalWindowManager.addView(Window.java:424)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.app.Dialog.show(Dialog.java:241)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.preference.DialogPreference.showDialog(DialogPreference.java:
307)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.preference.DialogPreference.onClick(DialogPreference.java:265)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.preference.Preference.performClick(Preference.java:810)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:
190)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.widget.AdapterView.performItemClick(AdapterView.java:284)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.widget.ListView.performItemClick(ListView.java:3382)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.os.Handler.handleCallback(Handler.java:587)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.os.Handler.dispatchMessage(Handler.java:92)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.os.Looper.loop(Looper.java:123)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
android.app.ActivityThread.main(ActivityThread.java:4627)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
java.lang.reflect.Method.invokeNative(Native Method)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
java.lang.reflect.Method.invoke(Method.java:521)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-23 11:36:59.630: ERROR/AndroidRuntime(816):     at
dalvik.system.NativeStart.main(Native Method)

package study.tabtabpref;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;

public class TabTabPref extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

                getTabHost().addTab(
                                getTabHost()
                                                .newTabSpec("LEFT")
                                                .setContent(
                                                                new Intent(this,
                                                                                
FillerActivity.class))
                                                .setIndicator("LEFT"));

                getTabHost().addTab(
                                getTabHost()
                                                .newTabSpec("RIGHT")
                                                .setContent(
                                                                new Intent(this,
                                                                                
InnerTabActivity.class))
                                                .setIndicator("RIGHT"));
    }
}


package study.tabtabpref;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;

public class InnerTabActivity extends TabActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.inner_tab);

                getTabHost().addTab(
                                getTabHost()
                                                .newTabSpec("INNER LEFT")
                                                .setContent(
                                                                new Intent(this,
                                                                                
FillerActivity.class))
                                                .setIndicator("INNER LEFT"));

                getTabHost().addTab(
                                getTabHost()
                                                .newTabSpec("INNER RIGHT")
                                                .setContent(
                                                                new Intent(this,
                                                                                
TabTabHostPreferences.class))
                                                .setIndicator("INNER RIGHT"));
        }
}


package study.tabtabpref;

import android.os.Bundle;
import android.preference.PreferenceActivity;

public class TabTabHostPreferences extends PreferenceActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                addPreferencesFromResource(R.xml.preference);
        }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to