7.1 Retrofit + OkHttp
interface Api { @GET("/users") suspend fun users(): List<User> }
val client = OkHttpClient.Builder()
.addInterceptor(HttpLoggingInterceptor().apply { level = BODY })
.build()
val retrofit = Retrofit.Builder()
.client(client)
.baseUrl("https://api.example.com")
.addConverterFactory(GsonConverterFactory.create())
.build()
val api = retrofit.create(Api::class.java)
7.2 序列化
- Gson 或
kotlinx.serialization:kotlin @Serializable data class User(val id: Int, val name: String)## 7.3 网络状态与错误处理 - 超时、重试、连接性监控(ConnectivityManager)。
📂 分类导航
-
▶
学与练
- ▶ 软件技术基础
- ▶ 前端开发技术
-
▶
后端开发技术
- ▶ 编程语言
- ▶ 中间件
-
▶
数据库
- MySQL
- SQLServer
- ▶ Dameng
- clickhouse
- Duckdb
-
▶
数据开发与运维
- ▶ 数据开发
-
▶
运维开发
- ▶ CI/CD
- ▶ 自动化
- ▶ 日志处理
- ▶ 监控
- 软件入门教程
- ▶ 课程库
-
▶
软件园
- AI智能体与应用
- ▶ 开发工具与环境
- AI 开发和编排
- 业务与生产力应用
- 数据和中间件
- ▶ 工具箱