There is an application main screen on which there are two textViews into which information received from the server is inserted. In order for the first launch of the application to go to the main screen you need to log in. After login, you can move to different activations, but when you press the button on the toolbar at home, you still return to the main screen. What is the actual problem - I have two widgets that are filled with information from the server and the correct information is not always displayed there. That is, it seems that a request has been previously sent and then the text is inserted into the widget. The logic of the application's behavior is this - after a successful login in the application, a Boolean variable with the value true is written to my device’s memory, which is then checked on subsequent launches of the application. If this variable is true then we will pass the login in the application and go to the main screen right away, if false then you need to login. For example, we logged in to the application for the first time, then after switching from the login screen to the main screen, the information in the textview looks correct and normal. But, further already, if we for example pass the login screen, then I get null there, although the request is normal. When you switch to the main screen from other activites, the information is also displayed normally and correctly, but when you start the activation, for some reason, everything is bad.
I tried to do it differently:
- In the onCreate () function, before the setContentView () function, I ran a method from a singleton, but it still did not help.
- I tried in the onStart () function to call a method and assign a value to global variables, but it also did not help.
I cannot understand why when switching from another activit to the main screen everything works correctly and as needed, but for some reason the activation of the main class doesn’t work as it should. Here is the function that I call:
MySingleton.getInstance().getPersonalData(); and then I pull the variables from the singleton:
name = MySingleton.getInstance().getAppl_name(); surname = MySingleton.getInstance().getAppl_lname(); id = MySingleton.getInstance().getA_id(); I can not understand what the problem is. I tried to throw some default value and then already if I had a request and the variables from the singleton are not empty, then I could write them to the widget but it did not work.