Interface world (Java + Android), Level 1: Callback method

preview_player
Показать описание
Interface world Java + Android, Level 1: Callback method !

* Callback method:
- "Don't call me, I'll call you".
- Main thread starts another thread to do something, when the
worker thread finishes, it calls the result back to the main thread.

* Java implement:
Step 1. Create a class as a worker.
Step 2. Create a callback interface.
Step 3. Worker class do something and call result back.
Step 4. Make callback deeper.
- Main thread doesn't know + doesn't care how and what thread is actually
did the work, it just handles the result, that's all.

* Android implement:
Step 1. Create MainActivity + a button to show custom dialog with 3 options.
Step 2. Create a custom dialog.
Step 3. Create a callback interface.
Step 4. Integrate callback and handle result.
Step 5. Make callback deeper.
- Main activity doesn't know + doesn't care how many dialogs is opened
to let user select, it just handle the final result.

Please like, share and subscribe !
Рекомендации по теме
Комментарии
Автор

Nice one
.. But, it would be great if you would have explained vocally instead of music.

thepowercareers
Автор

I got the answer, which I searched a lot.

vishnuv
Автор

This is exactly what I want. Thank you so much!

xiaoqin
Автор

Good Illustration... NICE explanation as well.

arunkumar-icrj
Автор

In your example main Thread doesn't starting another thread, you are using the same thread all the time.

weptechelektronikgmbh
Автор

Thank You very much for your lesson!!!! It help me too much)

МаленкоДмитрий
Автор

Awesome, hey is it possible to provide a custom asynchronous function example using interfaces like retrofit, volley.
Means working of a retrofit library, when i call an URL that not wait for its response and it handle with trigger like function onSuccess and onFailed .

wahidvi
Автор

Nice explanation but I have a question here! Is it necessary to use an Interface? Can't we make onFound a member of InterfaceWorld and then call the on onFound from ClassA using an instance of InterfaceWorld? Would you please explain that?

sharifyy
Автор

What a good tutorial, but how about lv2 & lv3? I'm looking forward to it !!!

다음만조
Автор

can i get a android callback code? i typed like your code but problem happened //optionaldialog.show() at this, show can't use in my androidstudio

xkjbsiw
Автор

bro thank you, but can you make video on level2, I saw in the project library but didnt found it on your channel, I am talking about the observable one

shrajan
Автор

The music is boring and distracts alot

altinshima
welcome to shbcf.ru