![]() ![]() Thus, there’s currently only one common way of implementing callbacks: via interfaces. You, me and all of the Android developers won’t be able to use those for a long time. Java doesn’t support lambda expressions or method references until Java 8. Unfortunately, there are not that many options on Android. This is important on Android in particular due to the fact that Android 4.0 or newer crashes the app when you execute network operations on the main thread! You’ve to move to some kind of asynchronous model. Thus, it makes sense to start the request (phone call) and rather take a notification when the response (answer phone call) is available than wait for the result. ![]() Because those go to a server somewhere on the Internet, there is no guarantee if and when we’ll get a response. Retrofit doesn’t make any phone calls, but has to fulfill a very similar function: network requests. Hopefully this quote explains fairly well what callbacks are and how we use them in programming. A function call is analogous to calling someone on a telephone, asking her a question, getting an answer, and hanging up adding a callback changes the analogy so that after asking her a question, you also give her your name and number so she can call you back with the answer. Before we go into the details, let’s start with an easy description of callbacks from Paul Jakubik:Ĭallbacks are most easily described in terms of the telephone system.
0 Comments
Leave a Reply. |