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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:24:56+00:00 2026-06-18T01:24:56+00:00

I am not able to execute the given code in emulator and it crashes

  • 0

I am not able to execute the given code in emulator and it crashes giving the error as shown in the log below.Here is my activity

import android.app.TabActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabContentFactory;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

@SuppressWarnings("deprecation")
public class Second extends TabActivity {
    private TabHost mTabHost;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
            mTabHost = (TabHost) findViewById(android.R.id.tabhost);
            setupTab(new TextView(this), "SRK/T");
            setupTab(new TextView(this), "SRK II");
            setupTab(new TextView(this), "HOLLADAY");
            setupTab(new TextView(this), "BINKHORST");
        }
        private void setupTab(final View view, final String tag) {
            View tabview = createTabView(mTabHost.getContext(), tag);
                TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(new TabContentFactory() {

                    public View createTabContent(String tag) {
                        // TODO Auto-generated method stub
                        return null;
                    }
                });
            mTabHost.addTab(setContent);
        }

        private static View createTabView(final Context context, final String text) {
            View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
            TextView tv = (TextView) view.findViewById(R.id.tabsText);
            tv.setText(text);
            return view;
        }

}

LOG FILE

    01-30 16:53:07.266: E/AndroidRuntime(382): FATAL EXCEPTION: main
01-30 16:53:07.266: E/AndroidRuntime(382): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.NullPointerException
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.os.Looper.loop(Looper.java:123)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.app.ActivityThread.main(ActivityThread.java:3683)
01-30 16:53:07.266: E/AndroidRuntime(382):  at java.lang.reflect.Method.invokeNative(Native Method)
01-30 16:53:07.266: E/AndroidRuntime(382):  at java.lang.reflect.Method.invoke(Method.java:507)
01-30 16:53:07.266: E/AndroidRuntime(382):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-30 16:53:07.266: E/AndroidRuntime(382):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-30 16:53:07.266: E/AndroidRuntime(382):  at dalvik.system.NativeStart.main(Native Method)
01-30 16:53:07.266: E/AndroidRuntime(382): Caused by: java.lang.NullPointerException
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.widget.TabHost$FactoryContentStrategy.getContentView(TabHost.java:625)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.widget.TabHost.setCurrentTab(TabHost.java:326)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.widget.TabHost.addTab(TabHost.java:216)
01-30 16:53:07.266: E/AndroidRuntime(382):  at com.example.iolcalci.Second.setupTab(Second.java:35)
01-30 16:53:07.266: E/AndroidRuntime(382):  at com.example.iolcalci.Second.onCreate(Second.java:21)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-30 16:53:07.266: E/AndroidRuntime(382):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-30 16:53:07.266: E/AndroidRuntime(382):  ... 11 more
01-30 16:53:09.026: E/InputDispatcher(60): channel '40730f58 com.example.iolcalci/com.example.iolcalci.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
01-30 16:53:09.026: E/InputDispatcher(60): channel '40730f58 com.example.iolcalci/com.example.iolcalci.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

I am not able to find the problem. Beginner here please help me

  • 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-18T01:24:57+00:00Added an answer on June 18, 2026 at 1:24 am

    Notice the error:

    01-30 16:53:07.266: E/AndroidRuntime(382): Caused by: java.lang.NullPointerException
    01-30 16:53:07.266: E/AndroidRuntime(382):  at android.widget.TabHost$FactoryContentStrategy.getContentView(TabHost.java:625)
    

    Then notice your code:

    .setContent(new TabContentFactory() {
          public View createTabContent(String tag) {
               // TODO Auto-generated method stub
               return null;
          }
    }
    

    This return null is causing the exception.

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

Sidebar

Related Questions

I am not able to execute this query getting ORA-00933: SQL command not properly
I am trying to execute the following query in oracle but not able to
I'm facing a Collection was modified; enumeration operation may not execute error in a
Hi:) I am not able to figure out what the error in the program
I am new to android. So, not able to trace out the error message
I keep seeing references to being able to execute code from the debugger, but
EDIT-4 I've gotten my sitecustomize.py to execute, but it tosses up an error. Here's
I have this code below where it is suppose to be able to display
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
Not able to store all binary data values into sqlite3 table using QT. For

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.