Web API Android Studio Kotlin Tutorial | REST

  Рет қаралды 19,943

Code With Cal

Code With Cal

Күн бұрын

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:
open.er-api.com/v6/latest/aud
Source code:
github.com/codeWithCal/FetchD...
⏱️ 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:
www.benq.com/en-au/monitor/st...
Eye-CareU | BenQ Monitor Software:
www.benq.com/en-au/monitor/so...
BenQ Screenbars:
www.benq.com/en-au/lamps/comp...
BenQ Screen bar plus:
www.benq.com/en-au/lamps/comp...
#AndroidStudio #KotlinProgramming

Пікірлер: 17
@AdityaYadav-py9yz
@AdityaYadav-py9yz 2 жыл бұрын
Great playlist cal, hope more people discover your work.
@EAteearsehole
@EAteearsehole Жыл бұрын
Not bad. Writing up-to-date. More vids like this please
@tamnguyen2009
@tamnguyen2009 Жыл бұрын
thanks so much bro . For opening my eyes. :)))
@kyanite8682
@kyanite8682 8 ай бұрын
Nice tutorial
@viacly7312
@viacly7312 Жыл бұрын
If anyone is having problems using this with Array of objects. Here is the solution. Use: val request: List = Gson().fromJson(inputStreamReader, Array::class.java).toList(). And updateUI function should be: private fun updateUI(request: List). In updateUI function you need to for loop your list. Sorry for bad explanation, but hopefully this helps someone out.
@kabirbajaj7225
@kabirbajaj7225 Ай бұрын
i am unable to loop through the object and display them what should i do exactly in the updateUI function?
@samuelcommander8611
@samuelcommander8611 2 жыл бұрын
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.
@CodeWithCal
@CodeWithCal 2 жыл бұрын
If they all have the same name then I believe you can put them into an array. This is in Java bit I believe it's what you are trying to do howtodoinjava.com/gson/gson-parse-json-array/
@samuelcommander8611
@samuelcommander8611 2 жыл бұрын
@@CodeWithCal Wahey, got my code working thanks to you. Cheers so much, keep up the vids.
@TimestampMaster
@TimestampMaster 2 жыл бұрын
Great video! Just curious, what’s your education/how did you learn these programming languages?
@CodeWithCal
@CodeWithCal 2 жыл бұрын
I studied IT in university, graduated in 2016. but that was really only a very basic understanding of java. Since then it's been self learning. I find i learn best by doing. and when i get stuck I google it, if theres a youtube video on the topic great otherwise stack overflow has some great information. Also the more time you spend programming the easier it is to swap languages, fundamentals of programming do not change in any programming language only syntax.
@antdx316
@antdx316 Жыл бұрын
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. : )
@CodeWithCal
@CodeWithCal Жыл бұрын
Absolutely.
@salgutierrez3272
@salgutierrez3272 2 жыл бұрын
Nice! You could have used Retrofit, no? (I'm new and just wondering if thats another way to do it?)
@CodeWithCal
@CodeWithCal 2 жыл бұрын
Probably, usually many different ways to solve a problem 🙂
@muhammadrayanmansoor4301
@muhammadrayanmansoor4301 Жыл бұрын
Brother from where do we know the response code should be 200 for a successful API request. Why the value is 200?
@CodeWithCal
@CodeWithCal Жыл бұрын
Good question, it's a http thing. The following should clear things up developer.mozilla.org/en-US/docs/Web/HTTP/Status
Retrofit in Android Studio using Kotlin | Android Knowledge
19:05
Android Knowledge
Рет қаралды 5 М.
Gym belt !! 😂😂  @kauermotta
00:10
Tibo InShape
Рет қаралды 18 МЛН
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 38 МЛН
Rest API - Best Practices - Design
15:50
High-Performance Programming
Рет қаралды 103 М.
Always Check for the Hidden API when Web Scraping
11:50
John Watson Rooney
Рет қаралды 614 М.
How to Make a News App | REST API | Android Project
1:26:06
Coding With Evan
Рет қаралды 86 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 47 М.
Kotlin for C# Developers - Alex Dunn
55:41
NDC Conferences
Рет қаралды 13 М.