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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:04:54+00:00 2026-05-30T18:04:54+00:00

Hi Friends i have written an Activity like below. SplashScreen.java public class SplashScreen extends

  • 0

Hi Friends i have written an Activity like below.

SplashScreen.java

public class SplashScreen extends Activity {

protected final int _splashTime = 4000;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    new Handler().postDelayed(new Runnable() {      
        public void run() {
            startActivity(mainIntent);*/
            Main mainObj=new Main();
            final Bundle bundle=new Bundle();
            mainObj.onCreate(bundle);
            finish();
        }
    }, _splashTime);
   }
}

From the above Activity iam calling Main.java which is as follows.

public class Main extends Activity{

public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);//line 1.

        setContentView(R.layout.main1);

      }

}

In the above Main.java in the line 1 while calling super.onCreate(savedInstanceState) iam getting NullPointerException.I have identified that if i call the Activity by creating an object using new operator it is giving NullPointerException like below

Main mainObj=new Main();

final Bundle bundle=new Bundle();

mainObj.onCreate(bundle);

But if i call an Activity using

startActivity(new Intent(SplashScreen.this,Main.claass));

iam not getting NullPointerException.So how can i run an Activity by creating an object using new opertor with out NullPointerException.

  • 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-30T18:04:56+00:00Added an answer on May 30, 2026 at 6:04 pm

    So how can i run an Activity by creating an object using new opertor with out NullPointerException.

    You should never attempt to create an instance of an Activity using new. This is not how Android works. The Activity class is a special case in Android (along with several other special Android components) and you need to create and manage them correctly.

    To create a new Activity you must always create a new Intent and use startActivity(...) or one of the other startActivityXXX(...) methods.

    See Application Fundamentals

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

Sidebar

Related Questions

friends, i have a EditText on simple activity with a button. when every i
I have a Person class. A person class contains a collection of Friends (also
Friends, I have written the following JavaScript to ascertain which row of an tabular
this is my algorithm that I have written it with my friends (which are
hi friends I have been working WCF since past one week. I have written
friends, i have written following layout code and buttons to be displayed on screen
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> I have written my HTML and
I have written the following Midje test: (fact (followers-minus-friends ...name...) => [Dude] (provided (idset
I have a complex json written in a string. I know java and a
I have a person class which has a name and a list of friends

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.