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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:56:11+00:00 2026-06-11T04:56:11+00:00

I am working on an application where i moving from list menu to tabhost

  • 0

I am working on an application where i moving from list menu to tabhost activity ,that is

Menu.class -> Recharge.class where
Recharge.class is a TabActivity
having a tab named prepaid.class

I need to pass a string from menu.class to prepaid.class
in the below code i passed the string please find the bug in my code and help me

Menu.class

    if(s.equals("Recharge"))
        {
            Intent i = new Intent(menu.this,recharge.class);
            i.putExtra("app",app);
            startActivity(i);

        }

Recharge.class

Intent i = this.getIntent();            
    final String app=(String)i.getStringExtra("app");
   Resources res = getResources(); 
    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec; 
    Intent intent;

    intent = new Intent().setClass(this, prepaid.class);
    intent.putExtra("app", app);

    //Prepaid
    spec = tabHost.newTabSpec("PREPAID").setIndicator("",
                      res.getDrawable(R.drawable.prepaid))
                  .setContent(intent);
    tabHost.addTab(spec);
    tabHost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.tabhost);

prepaid.class

Intent i=this.getIntent();
final String app=(String)i.getStringExtra("app");

This is the error in log:

09-10 14:37:44.038: E/AndroidRuntime(1172): FATAL EXCEPTION: main
09-10 14:37:44.038: E/AndroidRuntime(1172): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ezerecharge/com.example.ezerecharge.recharge}: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.ezerecharge/com.example.ezerecharge.prepaid}: java.lang.NullPointerException
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.os.Looper.loop(Looper.java:123)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.main(ActivityThread.java:3683)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at java.lang.reflect.Method.invokeNative(Native Method)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at java.lang.reflect.Method.invoke(Method.java:507)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at dalvik.system.NativeStart.main(Native Method)
09-10 14:37:44.038: E/AndroidRuntime(1172): Caused by: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.ezerecharge/com.example.ezerecharge.prepaid}: java.lang.NullPointerException
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1487)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.widget.TabHost.setCurrentTab(TabHost.java:326)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.widget.TabHost.addTab(TabHost.java:216)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at com.example.ezerecharge.recharge.onCreate(recharge.java:33)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-10 14:37:44.038: E/AndroidRuntime(1172):     ... 11 more
09-10 14:37:44.038: E/AndroidRuntime(1172): Caused by: java.lang.NullPointerException
09-10 14:37:44.038: E/AndroidRuntime(1172):     at com.example.ezerecharge.prepaid.<init>(prepaid.java:22)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at java.lang.Class.newInstanceImpl(Native Method)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at java.lang.Class.newInstance(Class.java:1409)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-10 14:37:44.038: E/AndroidRuntime(1172):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
  • 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-11T04:56:13+00:00Added an answer on June 11, 2026 at 4:56 am

    You are calling getIntent in the constructor. You cannot use it before the onCreate is called.

    Move your intitialization code from prepaid in prepaid.onCreate.

    And start your classes names by capital letters. please.

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

Sidebar

Related Questions

I am working on an android application that pulls data from a Database. I
I am working on moving an application from MVC2 ASPX to MVC3 Razor, and
I am having trouble starting up an old application that was working fine, but
I am working on splitting out an existing, working application that I currently have
I am working an application having I18N support. In this application, based on user's
I am working on an application that communicates with an external device via a
I'm working on a bug where I have an MFC application that does weird
I am working on a project that includes a Mac application and an iPad
I am moving a vb.net application from Oracle Lite to Sybase SQL anywhere. I
I am working on a MVC 3 application that will be hosted in 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.