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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:48:45+00:00 2026-05-23T04:48:45+00:00

I’m new to developing for Android and got really excited when I made my

  • 0

I’m new to developing for Android and got really excited when I made my first app (and fully understand it or so I thought), but I just can’t get it to run. It looks clean to me and I’m not sure what to look for based on the debug information. At least an explanation of what I should look for and why would be very much appreciated. I can provide any additional code you think would be helpful.

Thank you.

Here is my main Class:

package com.couchcode.realtime;

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

public class Realtime extends TabActivity {
    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

        makeTab("test");
    }
    private void makeTab(String tabTag) {
        intent = new Intent().setClass(this, SearchTab.class);
        View tabview = createTabView(tabHost.getContext(), tabTag);
        spec = tabHost.newTabSpec(tabTag).setIndicator(tabview).setContent(intent);
        tabHost.addTab(spec);
        tabHost.setCurrentTabByTag(tabTag);
    }       
    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;
        }
} 

And here is the output from logcat while running the debugger:

06-15 07:35:33.447: WARN/dalvikvm(25209): threadid=1: thread exiting with uncaught exception (group=0x401bd560)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209): FATAL EXCEPTION: main
06-15 07:35:33.477: ERROR/AndroidRuntime(25209): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.couchcode.realtime/com.couchcode.realtime.Realtime}: java.lang.NullPointerException
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.os.Looper.loop(Looper.java:130)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.ActivityThread.main(ActivityThread.java:3835)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at java.lang.reflect.Method.invokeNative(Native Method)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at java.lang.reflect.Method.invoke(Method.java:507)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at dalvik.system.NativeStart.main(Native Method)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209): Caused by: java.lang.NullPointerException
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.Activity.setContentView(Activity.java:1657)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.TabActivity.ensureTabHost(TabActivity.java:114)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.TabActivity.getTabHost(TabActivity.java:136)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at com.couchcode.realtime.Realtime.(Realtime.java:14)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at java.lang.Class.newInstanceImpl(Native Method)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at java.lang.Class.newInstance(Class.java:1409)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
06-15 07:35:33.477: ERROR/AndroidRuntime(25209):     ... 11 more
  • 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-23T04:48:45+00:00Added an answer on May 23, 2026 at 4:48 am

    You cannot call getTabHost where you are, which is effectively in your constructor. You must do it in your onCreate() method instead:

    public class Realtime extends TabActivity {
        TabHost tabHost;
        TabHost.TabSpec spec;
        Intent intent;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            tabHost = getTabHost();
            tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
    
            makeTab("test");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

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.