Android Studio Tutorial - Part 5 (2020 Edition)

Опубликовано: 08 Март 2020
на канале: DJ Malone
25,857
303

In this Android Studio tutorial we'll fetch a special message from a website I own. First, we'll use URL() to format the URL, then use Kotlin's readText() to fetch the message from that website. But this won't work, as we'll see in the video. What we need to do is use Kotlin Coroutines. Coroutines provides a way to do stuff in the background. So if my website takes 25 seconds to respond, the user isn't blocked from tapping on other parts of the app while the 25 seconds happens.

To use Kotlin Coroutines we need to first import the libraries from Google. We'll copy the implementation lines from GitHub and Google's official Android documentation website, pasting them into our build.gradle file. Be sure to sync Android Studio after adding these lines to the app.

The message: https://finepointmobile.com/api/inven...
Kotlin Coroutines: https://github.com/Kotlin/kotlinx.cor...
KTX library: https://developer.android.com/topic/l...

With these libraries imported we can update our TextView. Note that we'll also need to add the INTERNET permission to the AndroidManifest.xml file.

Be sure to use Dispatchers.Default instead of Dispatchers.IO, as I corrected at the end of the video ;)

Connect with me on LinkedIn!   / danielmalone  


На этой странице сайта вы можете посмотреть видео онлайн Android Studio Tutorial - Part 5 (2020 Edition) длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь DJ Malone 08 Март 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 25,857 раз и оно понравилось 303 зрителям. Приятного просмотра!