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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:29:51+00:00 2026-05-31T13:29:51+00:00

I want global variables that with highest level in this app so that it

  • 0

I want global variables that with highest level in this app so that it doesn’t need to be initialize when activity starts every time. I test my application on my physical device, and get nullPointerException. But success in emulator!!
log information:

03-15 15:36:54.851: E/AndroidRuntime(21550): 
java.lang.RuntimeException: Unable to start activity ComponentInfo{panda.com.db/panda.com.db.IndexActivity}: java.lang.NullPointerException
03-15 15:36:54.851: E/AndroidRuntime(21550):
at panda.com.db.LittleRabitAssistants.<init>(LittleRabitAssistants.java:83)
03-15 15:36:54.851: E/AndroidRuntime(21550):
at panda.com.db.Global.Init(Global.java:23)
03-15 15:36:54.851: E/AndroidRuntime(21550):
at panda.com.db.IndexActivity.onCreate(IndexActivity.java:38)

Code of global class:

public class Global extends Application{
    private static LittleRabitAssistants assistants;
    ..
    ..
    public void Init(){
        this.assistantsDB = new DBAdapter(this,null,null);
        this.assistants = new LittleRabitAssistants(this);
        this.initLocaleFromDB();
    }
}

public LittleRabitAssistants(Global globalVariable){
        this.globalVariable=globalVariable;
            ..
        if(globalVariable.getLocaleLanguage().equals("zh-CN")){
            ..
        }else{
            ..
        }   
    }

public class IndexActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        //get global application
        Global globalApplication = (Global)this.getApplication();
        //initialize the Assistants 
        globalApplication.Init();
        pa = globalApplication.getAsisstents();
}

However, the most important thing is, this application run successfully in emulator!!!

  • 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-31T13:29:51+00:00Added an answer on May 31, 2026 at 1:29 pm

    I think you have called the init() method before calling on the super.onCreate()…

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

Sidebar

Related Questions

So I got a lot of responses from this site that global variables are
I want watch for the creation of new global variables in Javascript so that,
I want to control global variables (or globally scoped variables) in a way that
I want to declare some global variables and global constants. Normally, I would put
I want to add this code: <link rel=stylesheet type=text/css href=css/global.css /> <!--[if lt IE
How can I create global variables that are shared in C? If I put
I have a javascript function (function1) that checks some global variables (can the user
I have some global variables in a Python script. Some functions in that script
I created a module Foo::Prototype with the global variables $A and $B. I want
I am working on a new PHP project now, this time I want to

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.