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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:33:11+00:00 2026-06-14T03:33:11+00:00

I have two activities (main and calculator). When a button in main is clicked,

  • 0

I have two activities (main and calculator). When a button in main is clicked, the activity changes to calculator, but I keep on getting an error while running at startActivity(intent)

MainActivity.java

public class MainActivity extends Activity {
    public final static String  EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
    public int mult = 1;

    public int num1;
    public int num2;
    public int answer;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }



    public void calculator(View view)
    {
        Intent intent = new Intent(this, CalculatorActivity.class);
        startActivity(intent);
    }


}

CalculatorActivity.java

public class CalculatorActivity extends Activity
{
    Button b0; 
    Button b1; 
    Button b2; 
    Button b3; 
    Button b4; 
    Button b5; 
    Button b6; 
    Button b7; 
    Button b8; 
    Button b9; 
    Button bDot; 
    Button bNeg;
    Button bDiv; 
    Button bMult;
    Button bSub; 
    Button bPlus;
    Button bEnter;

    EditText edit;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculator);

        //Intent intent = getIntent();


        //Intent intent = getIntent();
        b0 = (Button) findViewById(R.id.button0);
        b1 = (Button) findViewById(R.id.button1);
        b2 = (Button) findViewById(R.id.button2);
        b3 = (Button) findViewById(R.id.button3);
        b4 = (Button) findViewById(R.id.button4);
        b5 = (Button) findViewById(R.id.button5);
        b6 = (Button) findViewById(R.id.button6);
        b7 = (Button) findViewById(R.id.button7);
        b8 = (Button) findViewById(R.id.button8);
        b9 = (Button) findViewById(R.id.button9);
        bDot = (Button) findViewById(R.id.buttonDot);
        bNeg = (Button) findViewById(R.id.buttonNeg);
        bDiv = (Button) findViewById(R.id.buttonDiv);
        bMult = (Button) findViewById(R.id.buttonMult);
        bSub = (Button) findViewById(R.id.buttonMinus);
        bPlus = (Button) findViewById(R.id.buttonPlus);
        bEnter = (Button) findViewById(R.id.buttonEnter);

        edit= (EditText) findViewById(R.id.editText);
    }

    /** Called when the user clicks on a number */
    public void enterNum(View view)
    {
        b0.setOnClickListener(new OnClickListener()
        {
            public void onClick(View view)
            {
                edit.setText(b0.getText().toString());
            }
        });

        if(b0.isPressed())
            edit.setText( b0.getText().toString() );

    }
}
  • 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-14T03:33:12+00:00Added an answer on June 14, 2026 at 3:33 am

    while creating intent object try this

    intent=new Intent(MainActivity.this, CalculatorActivity.class);
    

    And check whether or not the CalculatorActivity is registered in the manifest file

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

Sidebar

Related Questions

I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have two activities, one is main and I have another activity called Test
i have two sub activities apart from main activity. The sequence of calls go
I have two Activities: Activity A and Activity B: 'A' is my Main Activity,
Let assume we have two activities. A - main activity, that is home launcher
I have two Activities. In my main Activity I am creating an intent to
suppose that you have two activities A(which is the main activity) and B when
Assume I have two activities. Activity A and Activity B, while Activity A is
I have two activities Main (with a button in it) & Second, and I

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.