Return code do not work

Leave I am going to use event

2 Likes

Yeah, right, it should always do it is not the main thread.

16.08.2021_17.58.55_REC

You can do it without an event.

There are magic Java classes that can do (asynchronously) without using the Deprecated AsyncTask of Android, this is a bit complicated to understand (at first) so it's not advisable to use this. :slightly_smiling_face:

@Kumaraswamy how did you made this block?

Do you know about while loop and Threed.sleep() method?

I am not using any kind of while loop or for a loop.

Then how you create that

Everyone thinks in different ways.

2 Likes

Well I'm using Callable with FutureRunnable, callable allows you to return anything when called just like runnable but this allows you to return values as well.

You can start the Callable object through the thread to start it and invoke the get method on it.
The main thread has to do nothing but wait for the call to finish.

Can you provide me code

You should make google your friend

Ok I am going to ask with google that Do you want to do friendship with me :joy::wink::stuck_out_tongue_winking_eye::rofl:

Let's not got too much off-topic :sweat_smile:

1 Like

Tell me how you do that

Generally we implement this pattern using a method-event pair. You run the asynchronous operation and the method returns immediately. Once the processing is complete, you use the runOnUiThread method to dispatch the event to the UI (blocks) thread. For an example, you can take a look at the File component.

4 Likes