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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:59:58+00:00 2026-06-18T11:59:58+00:00

I have code which should allow me to take value from calculator and use

  • 0

I have code which should allow me to take value from calculator and use it further:

//-----------------This section creates the keypad functionality
for (int o = 0; o < keybuttons.length; o++) {
    final int n = o;
    keybuttons[o] = (Button) findViewById(data.keyIds[n]);
    keybuttons[o].setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                String tmp = texts[selectEdit].getText()
                    .toString();
                switch (n) {
                case 3:
                    texts[selectEdit].setText(tmp.substring(0, tmp.length() - 1));
                    break; //get cursor position and delete char
                case 7:
                    {
                        // Create intent for RealCalc.
                        Intent intent2 = new Intent("uk.co.quarticsoftware.REALCALC");
                        double x = 0; // Set initial value (double).
                        if (!texts[selectEdit].getText()
                            .toString()
                            .equals("")) {
                            x = Double.valueOf(texts[selectEdit].getText()
                                .toString());
                        }
                        intent2.putExtra("X", x);
                        // Launch calculator
                        try {
                            startActivityForResult(intent2, 0);
                        } catch (ActivityNotFoundException e) {
                            Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=uk.co.nickfines.RealCalc"));
                            try {
                                startActivity(intent);
                            } catch (ActivityNotFoundException f) {
                                // Google Play Store app not available.
                            }
                        }
                        break;
                    } //open Calculator
                case 11:
                    {
                        if (!tmp.contains("E")) texts[selectEdit].setText(tmp + "" + keybuttons[n].getText());
                        break;
                    } //check for E if dont have do default case
                case 15:
                    {
                        TL.setVisibility(View.GONE);
                        break;
                    } //simulate back button
                default:
                    {
                        texts[selectEdit].setText(tmp + "" + keybuttons[n].getText());
                        //get cursor start and end and get entire String
                        // replace selected String with button text
                        //insert back
                        break;
                    }
                } //end of switch
            } //end of try
            catch (ActivityNotFoundException e) {
                Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=uk.co.nickfines.RealCalc"));
                // Calculator not installed
            } //calculator.num=n;
            catch (Exception e) {
                StringWriter sw = new StringWriter();
                e.printStackTrace(new PrintWriter(sw));
                EasyPhysActivity.error = sw.toString();
            }
        }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            if (resultCode == Activity.RESULT_OK) {
                // User pressed OK.
                double value = data.getDoubleExtra("X", Double.NaN);
                if (Double.isNaN(value)) {
                    // Calculation result was "Error".
                } else {
                    // Calculation result ok.
                }
            } else {
                // User pressed cancel or back button.
            }
        }
    });

}
//----------------------------------------

But it doesn’t like these three lines:

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

If I delete @Override it becomes better, but it still shows an error for

super.onActivityResult(requestCode, resultCode, data);

What is going wrong in here?

  • 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-18T12:00:00+00:00Added an answer on June 18, 2026 at 12:00 pm

    You cannot override onActivityResult inside OnClickListener because it does not exist in the base class. Move your onActivityResult code so that it is inside your Activity class, not the OnClickListner.

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

Sidebar

Related Questions

I have this code which should create a splash image with either no animation
I have the following code which should be getting the text from a span
I have a section of code which should be executed by a maximum number
This should be a pretty straightforward question. I have the following code, which forms
I have the following code which should put programs startable in Bash. if [
I have some validation code which should display the max / min of a
I have some code which I think should compile, but doesn't: import java.io.InputStream; import
I have the following lines of php code which should rename a file which
I have following code: os.chdir(os.path.dirname(os.path.realpath(__file__)) + /../test) path.append(os.getcwd()) os.chdir(os.path.dirname(os.path.realpath(__file__))) Which should add /../test to
I have the following code, which should adds a field to a form if

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.