'How come I can't retrieve a double value from a bundle using intents?
I looked into posts here and other sources and I can't seem to find a reason as to how come that my double value is not retrieved even though it is passed from the intent? Here the code with debugger output:
//First Activity
Intent intent = new Intent(this, Day1BarGraph.class);
intent.putExtra("stepsDay1", dailyTotalSteps);
intent.putExtra("date", currentTime);
intent.putExtra("day", dayWeekText);
intent.putExtra("ThursdayGoalValue", ThursdayGoal);
//Second Activity
Bundle extras = getIntent().getExtras(); // Debugger output Bundle[{ThursdayGoalValue=9000.0, day=Donnerstag, date=2022-02-03, stepsday1=0}]
stepValue = extras.getInt("stepsDay1");
day = extras.getString("day");
thursdayGoal = (int) extras.getDouble("ThursdayGoalValue");
When I continue to go through the code with the debugger I still get 0 as a value, for the variable thursdaygoal even though the debugger shows I am retrieving the value 9000. I can successfully retrieve the value from day. Which has Donnerstag (Thursday) as the associated value and store it in a variable. How come it does not work for the double value?
Note: It also works to retrieve the value for stepsday1. I did not test it for date. This should be irrelevant.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
