Web API Android Studio Kotlin Tutorial | REST

preview_player
Показать описание
How to fetch data from a web API and display with in android app using kotlin and android studio. In todays tutorial we build a very simple app that pulls currency data from a web server and we then decode that data from JSON format with gson which is a google plugin. the data is converted from JSON into our kotlin object and then displayed in some text views.

Example API:

Source code:

⏱️ TIMESTAMPS ⏱️
00:00 - Intro Web API
00:46 - BenQ Monitor ScreenBar
02:22 - API initial
03:02 - XML layout
04:42 - Fetch Data from API
06:16 - Internet Permission Android
06:55 - Decode JSON

27 inch FHD 1080p Eye-care IPS Monitor:

Eye-CareU | BenQ Monitor Software:

BenQ Screenbars:

BenQ Screen bar plus:

#AndroidStudio #KotlinProgramming
Рекомендации по теме
Комментарии
Автор

Great playlist cal, hope more people discover your work. <3

AdityaYadav-pyyz
Автор

If anyone is having problems using this with Array of objects. Here is the solution.
Use: val request: List<Request> = Gson().fromJson(inputStreamReader, And updateUI function should be: private fun updateUI(request: List<Request>). In updateUI function you need to for loop your list.

Sorry for bad explanation, but hopefully this helps someone out.

viacly
Автор

thanks so much bro . For opening my eyes. :)))

tamnguyen
Автор

great tutorial. it would be better with bigger fonts.

hasanozcifci
Автор

why skip the part where you created the project, and the xml file ? the page where you show the data from that api, i don't understand anything.

paulavram
Автор

This is a great video, super useful. Quick q - if this strategy were used to return info where each var in Currency had the same name, then how might you change the approach plz. I'm trying to adapt it to my own stuff but getting a bit stuck.

samuelcommander
Автор

It was missing a couple thing such as, if there is no internet the app shouldn't crash, fetching intervals, and it should stop fetching when the page is on the background but still this is great. : )

antdx
Автор

Great video! Just curious, what’s your education/how did you learn these programming languages?

TimestampMaster
Автор

Nice! You could have used Retrofit, no? (I'm new and just wondering if thats another way to do it?)

salgutierrez
Автор

Brother from where do we know the response code should be 200 for a successful API request. Why the value is 200?

muhammadrayanmansoor