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 6591117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:23:04+00:00 2026-05-25T17:23:04+00:00

I am using an ActivityGroup to open up Activity 2 from within Activity1, which

  • 0

I am using an ActivityGroup to open up Activity 2 from within Activity1, which lives under a TabHost. So I have a group of Tabs and Activity 1 is part of those, but when I click a button inside Activity 1 I want Activity 2 to open but still be under the tabs. This works fine using the following code:

    public void replaceContentView(String id, Intent newIntent) {
    View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); 
    this.setContentView(view);
} 

However, within Activity 2 I have a few spinners that inflate custom windows and call for using a SimpleCursorAdapter:

    @Override
    public View newDropDownView(Context context, Cursor cursor, ViewGroup parent) {
    super.newDropDownView(context, cursor, parent);
    View view = View.inflate(context, R.layout.custom_spinner_row, null);
    int labColumn = cursor.getColumnIndex("lab");
    String getLab = cursor.getString(labColumn);
    TextView lab = (TextView)view.findViewById(R.id.CustomSpinnerTitle);
    lab.setText(getLab);        
    return view;
    }

I am getting this error:

 09-21 02:33:16.644: ERROR/AndroidRuntime(1453): FATAL EXCEPTION: main
09-21 02:33:16.644: ERROR/AndroidRuntime(1453): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@40588a90 is not valid; is your activity running?
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.view.ViewRoot.setView(ViewRoot.java:527)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.app.Dialog.show(Dialog.java:241)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.widget.Spinner.performClick(Spinner.java:260)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.view.View$PerformClick.run(View.java:9080)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.os.Handler.handleCallback(Handler.java:587)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.os.Looper.loop(Looper.java:123)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at android.app.ActivityThread.main(ActivityThread.java:3683)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at java.lang.reflect.Method.invokeNative(Native Method)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at java.lang.reflect.Method.invoke(Method.java:507)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-21 02:33:16.644: ERROR/AndroidRuntime(1453):     at dalvik.system.NativeStart.main(Native Method)

The reason I am getting this error is because Activity 2 is not actually running because I replaced the contentView of Activity 1 with 2 in order to display it under the tabs. But I don’t know any other way to do that. Is there a way to run Activity 2 under my tabs by in the same way actually run the activity rather than just replacing the contentView of 1?

  • 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-25T17:23:04+00:00Added an answer on May 25, 2026 at 5:23 pm

    You are using ActivityGroup that deals with View, so when you are using ActivityGroup you cannot directly setContentView(R.layout.your_xml);. In that case you have to inflate your XML into View.

    So, replace setContentView(R.layout.your_xml) by

    View contentView = LayoutInflater.from(getParent()).inflate(R.layout.your_xml, null);
    setContentView(contentView);
    

    Hope this works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application is Tab using ActivityGroup.I have done title of each activity using getParent().getParent().setTitle(New
I am using an ActivityGroup to spawn multiple activities and switch views from within
I'm using ActivityGroup for my tabs. In my TabActivity onCreate tabHost = getTabHost(); TabHost.TabSpec
I'm developing an app which contain TabHost ,in one of those tabs i have
I have one problem using ActivityGroup . I have two activities inside an ActivityGroup
I have an issue where I have an ActivityGroup using TabActivities. Everything works great
I am working with ActivityGroup and I want to open an sub activity of
i have 4 tab with activity group..all tab contain list of item and on
I have a tab activity, and inside one tab I have activitygroup. Initially activity
In my application I have a Tabbar and I am using ActivityGroup to load

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.