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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:15:12+00:00 2026-05-24T11:15:12+00:00

I use the Android support library to use fragments in pre Honeycomb Applications. If

  • 0

I use the Android support library to use fragments in pre Honeycomb Applications.

If I add a fragment inside the onCreate method of my activity the activity crashes with an IllegalStateException.

08-04 10:19:49.100: ERROR/AndroidRuntime(18501): FATAL EXCEPTION: main  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501): java.lang.RuntimeException: Unable to start activity ComponentInfo{net..../net.....homescreen...Main}: java.lang.IllegalStateException: Activity has been destroyed  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.os.Handler.dispatchMessage(Handler.java:99)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.os.Looper.loop(Looper.java:123)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.app.ActivityThread.main(ActivityThread.java:3691)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at java.lang.reflect.Method.invokeNative(Native Method)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at java.lang.reflect.Method.invoke(Method.java:507)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at dalvik.system.NativeStart.main(Native Method)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501): Caused by: java.lang.IllegalStateException: Activity has been destroyed  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1257)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:535)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:519)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at net.....AbstractActivity.onCreate(AbstractActivity.java:103)   
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at net.....homescreen...Main.onCreate(..Main.java:51)   
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)  
08-04 10:19:49.100: ERROR/AndroidRuntime(18501):     ... 11 more  

The onCreate of the AbstractActivity looks like this:

protected void onCreate(Bundle savedInstanceState) {
    if (menuEnabled) {
        FragmentManager fragmentManager = getCompatibleFragmentManager();
        FragmentTransaction transaction = fragmentManager
                .beginTransaction();
        transaction.add(new OptionsMenuFragment(), OPTIONS_MENU_IDENTIFIER);
        transaction.commit();
    }
    super.onCreate(savedInstanceState);
}

If I debug the call I see that the fragmentmanager throws this exception because the activity is null. It seems that the fragmentmanager is not initialized at all.

What am I 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-05-24T11:15:13+00:00Added an answer on May 24, 2026 at 11:15 am

    It turns out that the FragmentActivity from the compatibility packages initializes the fragment manager in the onCreate method itself.

    If I move the call to super to the beginning of my onCreate method everything works fine.

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

Sidebar

Related Questions

Any ideas what is the best Encryption library to use for Android that support
I try to use the Android compatibility library (or now called the support library)
What font file types does Android support (for use with Typeface.createFromAsset, for instance)? I
I use class from How to support Arabic text in Android? to show Arabic
I am trying to use Jake Wharton's ActionBarSherlock to support actionbars in android projects
My app is currently using the Fragments/v4 compatibility package to support Android versions all
I want to use HTML5 support in android webview. when I am trying to
I'm trying to use the ActionBarSherlock library to provide backwards compatible ActionBar support with
i know how to proguard android project,but at present i use android do a
I am currently trying to research how to use Android with an existing java

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.