Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6679953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:25:07+00:00 2026-05-26T04:25:07+00:00

I have a TabActivity where each tab has ActivityGroup. On the home ActivityChild of

  • 0

I have a TabActivity where each tab has ActivityGroup.
On the home ActivityChild of the first group I have an menu option, which gives to the user the option to open preferences.
When I click “Preferences” on menu, I start PreferenceActivity inside ActivityGroup, which shows PreferenceActivity on the first tab.
The problem is when I click on any specific preference which has to show a Dialog (for EditTextPreference).
I have the following exception:

android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@405d3a20

I understand that the problem is because Dialog to be shown by PreferenceActivity uses wrong context, BUT i don’t now how change the context of created dialog.

Belows is the PreferenceActivity I’ve created.

public class PreferencesActivity extends PreferenceActivity  implements OnSharedPreferenceChangeListener{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.preferences);
        addPreferencesFromResource(R.xml.preferences);
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        prefs.registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key) {     

    }   
}

I don’t want to create custom dialogs. I want to use the mechanism of PreferenceActivity for that.
Below is the code that I’m using to add to group:

i = new Intent(MyActivity.this, PreferencesActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity) getParent();
parentActivity.startChildActivity("PreferencesActivity", i);

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:25:07+00:00Added an answer on May 26, 2026 at 4:25 am
    This is very common problem with dialog's in Tab Host.
    
    Actually the Activity context is not sufficient to show a Dialog in Tab.
    
    
    You have to use the context of your GroupActivity for the dialog to be enabled without exception
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tabactivity with several tabs. Each tab has an ActivityGroup associated with
I have a tabActivity which has 3 tabs and 3 different activities in each
I have a TabActivity with 5 tabs in it and each tab has an
I have a TabActivity that has a TabHost with two tabs. Each tab has
My application has a TabActivity which contains 4 tabs. Each tab contains the corresponding
i have TabActivity in android project which contains some tabs. In each tab i
In android, I have a TabActivity with 2 tabs and each tab has it
I have a TabActivity with three tabs defined. The first tab is light-weight and
I have a TabActivity with several tabs. Each tab corresponds to a specific view,
I have a TabActivity with a tab, which shows a list. I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.