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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:41:43+00:00 2026-06-03T03:41:43+00:00

I have a FragmentActivity with the following onCreate method that seems to crash on

  • 0

I have a FragmentActivity with the following onCreate method that seems to crash on mobile devices using Android 2.1 or below. Any ideas on what could be causing this error ?

The exception being thrown when this activity is started :

04-25 20:00:41.834: E/AndroidRuntime(381): Uncaught handler: thread main exiting due to  uncaught exception
04-25 20:00:41.877: E/AndroidRuntime(381): java.lang.NullPointerException 
04-25 20:00:41.877: E/AndroidRuntime(381):  at    android.widget.TabHost.dispatchWindowFocusChanged(TabHost.java:295)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1819)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.os.Looper.loop(Looper.java:123)
04-25 20:00:41.877: E/AndroidRuntime(381):  at android.app.ActivityThread.main(ActivityThread.java:4363)
04-25 20:00:41.877: E/AndroidRuntime(381):  at java.lang.reflect.Method.invokeNative(Native Method)
04-25 20:00:41.877: E/AndroidRuntime(381):  at java.lang.reflect.Method.invoke(Method.java:521)
04-25 20:00:41.877: E/AndroidRuntime(381):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-25 20:00:41.877: E/AndroidRuntime(381):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-25 20:00:41.877: E/AndroidRuntime(381):  at dalvik.system.NativeStart.main(Native Method)

And part of my FragmentTabs class

public class FragmentTabs extends SherlockFragmentActivity
{
protected static final int RESULT_CLOSE_APPLICATION = 666;
protected static final int RESULT_RESET_USER = 667;
LoginController loginControl;
Context ctx;
Fragment lastFragment;
int initRun;
boolean isRoot;

/**
 * Decklare tabs and associate them with their respective initial fragments.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_tabs);
    ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);
    ActionBar.Tab tabA = bar.newTab().setText("Forside");
    ActionBar.Tab tabB = bar.newTab().setText("Indstil");
    ActionBar.Tab tabC = bar.newTab().setText("Mere");

    tabA.setTabListener(new MyTabsListener(new FrontpageFragment()));
    tabB.setTabListener(new MyTabsListener(new SettingsFragment()));
    tabC.setTabListener(new MyTabsListener(new MoreFragment()));

    bar.addTab(tabA);
    bar.addTab(tabB);
    bar.addTab(tabC);

}

I tried the answer provided here but I don’t think the solution applies to my app. I do think it is related to the “Tab bar”.

  • 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-03T03:41:44+00:00Added an answer on June 3, 2026 at 3:41 am

    I’m having the same issue. While I could not finally solve it, I at least have some hint already that might help:

    In Android 2.1, the method TabHost.dispatchWindowFocusChanged did not yet check for null values of mCurrentView: (from TabHost.java in the Android source v2.1)

    @Override
    public void dispatchWindowFocusChanged(boolean hasFocus) {
        mCurrentView.dispatchWindowFocusChanged(hasFocus);
    }
    

    In Android 2.2 and later, this check for a null value has been inserted: (from TabHost.java in the Android source v2.2)

    @Override
    public void dispatchWindowFocusChanged(boolean hasFocus) {
        if (mCurrentView != null){
            mCurrentView.dispatchWindowFocusChanged(hasFocus);
        }
    }
    

    Why exactly mCurrentView is null here I don’t know. But this at least explains why it only happens in Android 2.1 and not in 2.2+.

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

Sidebar

Related Questions

I have the following code: import android.support.v4.app.FragmentActivity; import android.support.v4.app.Fragment; public void onCreate(Bundle savedInstanceState) {
I'm developing an Android 3.1 Tablet application using android.support.v4.view.ViewPager and android.support.v4.app.FragmentActivity . The following
Using android-support-v4.jar and FragmentActivity (no fragments at this point) I have an AsyncTaskLoader which
I have a FragmentActivity using a ViewPager to serve several fragments. Each is a
In my app I have a FragmentActivity that implements ListFragment.OnSelectedListener. The ListFragment uses a
I have class that extend FragmentActivity in it I add fragment to layout as
I have a fragment where I wish to call a method from the FragmentActivity
I have a FragmentActivity where I'm dynamically adding Fragment s in my onCreate .
So I have an FragmentActivity that contains 3 tabs, one tab is essentially a
I am using the Android Compatibility Package with API Level 10. I have a

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.