I have a question about android delay

Asked 2 years ago, Updated 2 years ago, 26 views

There is a code that receives information from an external server among the codes I am working on. There is a delay while receiving it.

new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                checkNickname(connection,token); //Run in 0.5 seconds
            }
        }, 500);

We are giving a delay in the same way as above. However, because of this specific time delay, the server gets slower, or the slow phone doesn't get the price, and the app dies due to nullpointer. Is there a way to run the function if you get a value other than this specific time? I thought of a way to loop through the while statement as one of the methods, but it didn't seem like a good method. I ask for your good opinions!

android

2022-09-22 14:27

1 Answers

Event buses can be an alternative in an easy and quick way to apply. Please check the contents below.


2022-09-22 14:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.