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

  • SEARCH
  • Home
  • 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 9312233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:34:40+00:00 2026-06-19T01:34:40+00:00

I need implement nested Activities in TabHost in my app. I use such ActivityGroup

  • 0

I need implement nested Activities in TabHost in my app. I use such ActivityGroup class :

  public class CustomActivityGroup extends ActivityGroup {

View rootView;


public static CustomActivityGroup group;


private ArrayList<View> history;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.history = new ArrayList<View>(); group = this;



      View view = getLocalActivityManager().startActivity("LoginActivity", new Intent(this,RegisterActivity.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
      .getDecorView();
      replaceView(view);


}

@Override
protected void onResume() {

    super.onResume();
    this.history = new ArrayList<View>();
    group = this;

}

public void replaceView(View v) {

    if (history.size() == 0) {
        if (rootView != null) {
            history.add(rootView);
            rootView = null;
        }
    }
    history.add(v);  
    setContentView(v);
}

public void back() {
    try {
        if (history.size() > 0) {
        history.remove(history.size() - 1);
        if (history.size() > 0) {
            setContentView(history.get(history.size() - 1));
        } else {
            finish();
        }
    } else {
        finish();
    }
    } catch (Exception ex) {
    }
}

public int getHistorySize() {
    return history.size();
}

@Override
public void onBackPressed() {
    try {
        CustomActivityGroup.group.back();
    } catch (Exception ex) {

    }
    return;
}
}

and in my TabActivity:

  intent = new Intent().setClass(this, CustomActivityGroup.class);

    spec = tabHost.newTabSpec("tab_2").setIndicator("Sign up",getResources().getDrawable(R.drawable.signup)).setContent(intent);
    tabHost.addTab(spec);

but when I click on corresponding tab I get

 FATAL EXCEPTION: main
 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assignmentexpert/com.activitygroups.CustomActivityGroup}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assignmentexpert/com.assignmentexpert.RegisterActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@405ceb00 is not valid; is your activity running?
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1491)
    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)

    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:676)
    at android.widget.TabHost.setCurrentTab(TabHost.java:348)
    at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:141)
    at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)
    at android.view.View.performClick(View.java:2485)
    at android.view.View$PerformClick.run(View.java:9080)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:3687)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assignmentexpert/com.assignmentexpert.RegisterActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@405ceb00 is not valid; is your activity running?
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1491)
    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
    at com.activitygroups.CustomActivityGroup.onCreate(CustomActivityGroup.java:31)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
    ... 18 more
 Caused by:  Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@405ceb00 is not valid; is your activity running?
    at android.view.ViewRoot.setView(ViewRoot.java:532)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
    at android.view.Window$LocalWindowManager.addView(Window.java:424)
    at android.app.Dialog.show(Dialog.java:241)
    at com.asynctaskbase.AbstractTaskProgressDialogFragment.onCreateDialog(AbstractTaskProgressDialogFragment.java:68)
    at com.asynctaskbase.AbstractTaskProgressDialogFragment.onCreateDialog(AbstractTaskProgressDialogFragment.java:1)
    at android.support.v4.app.DialogFragment.getLayoutInflater(DialogFragment.java:295)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:523)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
    at android.app.Activity.performStart(Activity.java:3791)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
    ... 24 more

What I’m doing wrong?

  • 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-06-19T01:34:41+00:00Added an answer on June 19, 2026 at 1:34 am

    I found the reason of this issue. I added my FragmentActivities to ActivityGroup and then used them in the TabHost. When I clicked the button which called ProgressDialog I got this exception. I should create it like this

    progressDialog = new ProgressDialog(getActivity().getParent());
    

    , not

     progressDialog = new ProgressDialog(getActivity());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement nested transactions in .NET using ADO.NET . The situation is
I need to implement an efficient excel-like app. I'm looking for a data structure
I need to implement a simple monitoring app in Excel. It is for monitoring
I have some nested view models that implement INotifyPropertyChanged . I'd like to bind
I need to implement nested group membership for generic AD services. Previously, i was
I need to implement a nested grid functionality in extjs 4. I searched online
I need to implement portable code, but I do not know how to deal
I need to implement the following: There is a table A which is supposed
i need to implement the email signature with image.As of now we only support
I need to implement AI for game based on fuzzy logic. I need 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.