i have made an app that would calculate numbers from input fields.
**main Activity
input1
input2
input3
these input are for user to enter numbers.
input5 has a preset number of 9.5
input4 is in “details” activity
“Total” should add input1,input2,input3 and input4
the problem i am having is that when i try to calculate the “total” would not pull input4 number from the second Activity unless i go to that screen and go back to main then click on calculate. could anyone help me figure out how to run both main and the details activities at the same time with the main Activity on the main screen.
thank you for reading.and helping me through this.
There are a number of ways to share static data across activities. You could use the
PreferenceManagerapi,Serviceor even extendApplicationto hold your global data.Another way would be to put the info inside the
Intentwhen you create your new activity. withputExtra("input1key",input1);(assuming you are calculating with ints you could use float, etc) then in your new activity.int input1 = getIntent().getIntExtra("input1key", 0);