Zagran-tour - Cập nhật bản tin du lịch xu hướng mới nhất hiện nay
  • Home
  • Du Lịch
No Result
View All Result
  • Home
  • Du Lịch
No Result
View All Result
Zagran-tour - Cập nhật bản tin du lịch xu hướng mới nhất hiện nay
No Result
View All Result

Retrofit Tutorial Part 1 – SIMPLE GET REQUEST – Android Studio Tutorial

admin by admin
June 30, 2020
in Uncategorized
32
Retrofit Tutorial Part 1 – SIMPLE GET REQUEST – Android Studio Tutorial



In this video series we will learn how to use Retrofit, which is a type-safe HTTP client for Android and Java.
Retrofit allows easy communication with a web service by abstracting the HTTP API into a Java interface.

In part 1 we will set up Retrofit in a new Android Studio project by adding the necessary Gradle dependencies, and then already do our first GET request.
We create an interface with 1 method that we annotate with @GET and the relative URL to the API endpoint of the REST API we want to query. We then create a Retrofit instance, define the baseUrl, add GSON as the converter by passing GsonConverterFactory to the addConverterFactory method, and let Retrofit create the implementation of our API interface at compile time.
The Call object that our GET method returns encapsulates a single request + response. With enqueue we can execute this request asynchcronously on a background thread and get our result back in the onResponse callback. OnFailure will be called if something in the process of communicating with the server or processing the response went wrong. With isSuccessFull we check if our response code is between 200 and 300 and if that’s the case we can retrieve our result from the response body.
GSON will parse the array of JSON objects into a List of the Java model class that we prepared beforehand.

Watch the whole playlist:

Example code, links & dependencies:

____________________
❗ Subscribe to the channel:

⏯ Watch more tutorials:

⭐ Become a channel member for exclusive tutorials and other perks:

㊙ Help translating the videos:

💚 Support the content:

💬 Join the Discord chat:

🎧 Audiobooks and podcasts for programmers:

👶 How to get started with Android development:

📣 Follow Coding in Flow on social media:

Facebook:

Instagram:

Twitter:

Blog:

Nguồn: https://zagran-tour.com/

Xem thêm bài viết khác: https://zagran-tour.com/cong-nghe/

Xem thêm Bài Viết:

  • Cakhia tv trực tiếp bóng đá và chia sẻ tin tức mới nhất
  • Điểm qua 5 dòng máy đùn xúc xích HOT nhất thị trường
  • Top 10 phần mềm CRM miễn phí tốt nhất cho doanh nghiệp
  • Sinh năm 1995 mệnh gì? Tuổi Kỷ Hợi hợp với màu gì & hợp với màu gì?
  • Phần mềm Quản lý Bất động sản Đáng Đầu tư Hôm nay
Previous Post

Animating in Blender 2.8 - First Person Character Game Weapons (Tutorial Series Trailer)

Next Post

Thụt lề đầu dòng trong word

Next Post
Thụt lề đầu dòng trong word

Thụt lề đầu dòng trong word

Comments 32

  1. Muhammad Kamal says:
    3 years ago

    make your life easy
    the latest version of retrofit for example 2.9.0 will cause an error
    use this instead :

    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

    Reply
  2. Jonasz Przybycień says:
    3 years ago

    Here's an example:
    I want to access this rest api https://danepubliczne.imgw.pl/api/data/synop so I write https://danepubliczne.imgw.pl/ in .baseUrl and the relative address in @GET. But all I get is zeroes. My repo is here:
    https://github.com/Zemogiter/AmaWeatherApp
    Any help?

    Reply
  3. yah chan says:
    3 years ago

    is this playlist all about networking ?

    Reply
  4. beingknow says:
    3 years ago

    Thank you so much, also clapping in end 😍

    Reply
  5. Ahmad Jamous says:
    3 years ago

    I'm trying to get list of object from my api but i got an error called: expected begin_array but was begin_object i didn't find the solution can you help ?

    Reply
  6. Adittya Raj says:
    3 years ago

    Danke Schon!!!

    Reply
  7. DRIVE MAN says:
    3 years ago

    Hello teacher, I have been following you for almost a year, and I am happy about that, but I find something that is missing from me, which is how to display specific data from the table for each employee as each employee sees the work required of him only

    Reply
  8. Shakeel Haider says:
    3 years ago

    sir I use retrofit in my own project with flask backend and face SSL Handshake Error. I Google it but nothing found :(. could you please help me to resolve the error.

    Reply
  9. pedram says:
    3 years ago

    thanks you so much

    Reply
  10. pedram says:
    3 years ago

    so good explain the code. thank you

    Reply
  11. Pandurang P Naik says:
    3 years ago

    What if their is only base url available?

    Reply
  12. Ravi Sorathiya says:
    3 years ago

    Is it always preferable use to retrofit library compare to other library

    Reply
  13. Arpit Gupta says:
    3 years ago

    Is this in JAVA?

    Reply
  14. Pandurang P Naik says:
    3 years ago

    please use recycler view

    Reply
  15. xxthebbkidxx says:
    3 years ago

    My data is returning null my base url is :.baseUrl("https://covidtracking.com/") and my relative url is : @GET("api/states")

    Reply
  16. Akhil Pandey says:
    3 years ago

    Thank you so much for these free tutorials! I just got my very first internship as an android app developer and now I have to learn and get used to these things, you're videos are really helpful. You're a lifesaver! Love from India <3

    Reply
  17. Youness labghough says:
    3 years ago

    how to can i connect my localhost server ????

    Reply
  18. Rahul Pandey says:
    3 years ago

    Starting with version 2.7.0 (December 2019), Retrofit now requires at minimum Java 8+ or Android API 21+. So if you're seeing a runtime exception about "No static method metafactory", add this into your build.gradle file in the app module.
    android {
    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }
    …
    }

    Reply
  19. Sinb O'bey says:
    3 years ago

    Hi, Thanks for the tutorial. As mentioned in the video as your plan to do, do you have another tutorial combining retrofit with android architecture components?

    Reply
  20. Rajmanov says:
    3 years ago

    But the most spoken language is Chinese, more people don't speak English that people than do, that's a very bad analogy btw

    Reply
  21. LearnTech in Hindi says:
    3 years ago

    i want to know if our json object is not in proper sequence and also we have to sequence the object the How we gonna do with retrofit??? Is retrofit method is more complex than the normal one without any library??

    Reply
  22. hamza abuammar says:
    3 years ago

    can I send from my android app csv file to flask server?
    I will generate dataset from android as csv file, send it to machine learning model hosted on flask server, and return the prediction.

    Reply
  23. Daniel Prowse says:
    3 years ago

    at 1:34am.. the clapping at @19:15 scared the shit out of me 🤣 Great video!

    Reply
  24. Adel Benhamida says:
    3 years ago

    Thank you so much, your video just made me continue my last Project which i was stuck in !

    Reply
  25. Chimezie Orji-Unegbu says:
    3 years ago

    Your videos are truly amazing that I have decamped from one I always thought was el dorado to yours, thanks.

    However I keep getting the exception javax.net.ssl.SSL ProtocolException. It makes me sad

    Reply
  26. Arpit Rastogi says:
    3 years ago

    I have created a working example on GitHub with latest dependencies, for reference – https://github.com/rastoarpit/Retrofit2_Java

    Reply
  27. Rima rima says:
    3 years ago

    Beautiful. Bless u

    Reply
  28. Khairul Islam says:
    3 years ago

    Hi jsonplaceholder site is error now

    Reply
  29. pmig81 says:
    3 years ago

    How would you make the call with Retrofit if you had an object and an array of objects? Would you need 2 pojo's ?
    like this, for example : https://api.covid19api.com/summary

    Reply
  30. pmig81 says:
    3 years ago

    Thanks for all the great tutorials.

    Reply
  31. Da Jo says:
    3 years ago

    When I try to do what you do my app doesn't start anymore with the message "app keeps stopping".
    This is the code:
    https://pastebin.com/JqwwNcBS

    If I remove everything except the api class and the "RKIApi rkiApi = getRetrofitInstance().create(RKIApi.class);" it still happens.

    Reply
  32. PBoroGamer says:
    3 years ago

    Danke, du bist toll!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Xem Thêm

Chiêm ngưỡng toàn cảnh Myanmar | Ảnh: kenhhomstay

Săn vé máy bay đi Myanmar- Kinh Nghiệm Vi Vu Miến Điện

January 13, 2023
Bãi biển Cát Bà

Top 7 bãi biển gần Hà Nội đẹp nhất có thể di chuyển bằng xe máy

December 13, 2022
Du lịch Phú Quốc – 3 ngày 2 đêm ở Vinpearl

Du lịch Phú Quốc – 3 ngày 2 đêm ở Vinpearl

July 9, 2021
MUA VÉ MÁY BAY GIÁ RẺ: NÊN CHỌN JETSTAR PACIFIC HAY VIETJET AIR??? | VIETNAMBOOKING.COM

MUA VÉ MÁY BAY GIÁ RẺ: NÊN CHỌN JETSTAR PACIFIC HAY VIETJET AIR??? | VIETNAMBOOKING.COM

July 9, 2021
Giới Thiệu Tour Du Lịch Huế – Hòa Bình Tourist

Giới Thiệu Tour Du Lịch Huế – Hòa Bình Tourist

July 9, 2021
Vingroup xây dựng công viên chủ đề 1 tỷ usd tại Hải Phòng

Vingroup xây dựng công viên chủ đề 1 tỷ usd tại Hải Phòng

July 9, 2021
  • Liên Hệ
  • Chính Sách Bảo Mật

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Du Lịch

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.