How can I run 2 actions simultaneously

I made an application that will calculate numbers from input fields. ** The main activity of input1 input2 input3 this input is intended for user input numbers. input5 has a predefined number of 9.5 input4 is in the "details" mode.

"Total" should add input1, input2, input3 and input4

The problem I am facing is that when I try to calculate the "total", you will not get the input number4 from the second activity, unless I go to this screen and return to the main one, and then click on the calculation. can someone help me figure out how to simultaneously launch both basic and detailed actions with the main action on the main screen. thank you for reading. And helping me with that.

+4
source share
2 answers

There are several ways to exchange static data between actions. You can use the PreferenceManager api, Service or even extend the Application to store global data.

Another way is to place the information inside the Intent when creating a new action. with putExtra("input1key",input1); (assuming that you are calculating using ints, you can use float, etc.), then in your new action. int input1 = getIntent().getIntExtra("input1key", 0);

+3
source

Along with @schwiz's answer, you can also rethink your design. Do I need to use 2 events here? What for? What is the use of using 2 types of activity in this case? We really cannot answer without seeing some features.

+1
source

Source: https://habr.com/ru/post/1334019/


All Articles