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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:07:02+00:00 2026-06-17T03:07:02+00:00

I am trying to pass data between two activities in my android application however

  • 0

I am trying to pass data between two activities in my android application however when
i try the run the on click method that sends the data the app crashes.

This is the code of the activity that works out my calculation is trying to send it to another activity called result. The variable output I am trying to send is a double.

Intent myIntent = new Intent(BMIMetric.this, result.class);
BMIMetric.this.startActivity(myIntent);
myIntent.putExtra("key", output);

Then on the results page I am trying to take the variable with this code

Intent myIntent = getIntent();
double output = (Double) getIntent().getExtras().get("Key");
  • 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-17T03:07:03+00:00Added an answer on June 17, 2026 at 3:07 am

    First, you have an order issue (edited code):

    Intent myIntent = new Intent(BMIMetric.this, result.class);
    myIntent.putExtra("key", output);
    BMIMetric.this.startActivity(myIntent);
    

    You need to set extras before starting the new Activity.

    Then in your other Activity do:

    Intent myIntent = getIntent();
    double output = getDoubleExtra ("key", -1.0);
    

    getDoubleExtra() seems like a better fit since you’re assigning to a primitive data type.

    Also, as Blumer mentioned, "key" had a different spelling. You need the same spelled key, that’s how it works. Otherwise you’re mentioning something different and it won’t be found.

    And as an addition to using getExtras() – if you use getExtras().get() and the key is not found, you will get null in return. Although Doubles can auto-box/unbox nowadays, if you do

    Double doubleObject = null;
    double d = doubleObject;
    

    You will still get a NullPointerException.

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

Sidebar

Related Questions

I am trying to pass data between two activities that are inside of tabs.
I am trying to make an app that will pass data between two servers
Possible Duplicate: Passing data between activities in Android I'm trying to pass a string
I am trying to pass data between two pages using Session State in ASP.NET.
I am trying to use SequenceFile to pass data between two mapReduce programs. The
So i'm trying to pass data between two views (first view is tableViewController,when cell
I'm trying pass data between applications that was encrypted using the Horde/phpmyadmin blowfish.php library
I'm trying to pass array lists between activities in Android. The lists contains strings.
I'm trying to create a simple project to pass some data between two view
I'm trying to write my own protocol so that multiple servers can pass data

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.