發表文章

Privacy Policy

**Privacy Policy** David built the Foxconn TWS app as a Free app. This SERVICE is provided by David at no cost and is intended for use as is. This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service. If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy. The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Foxconn TWS unless otherwise defined in this Privacy Policy. **Information Collection and Use** For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request will be retai

Retrofit 使用教學

markdown ## Retrofit簡介 Retrofit 是一個網路連結套件,可以在連結網路的時候做好封裝的效果,可以跟 OkHttp 以及 RxJava 合併使用 ## Retrofit應用 使用到的三方套件: ``` Java implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.okhttp3:okhttp:3.11.0' ``` 首先要先產生出Retrofit的實體物件: ```Kotlin class RetrofitServiceGenerator private constructor() { private val retrofit: Retrofit private val okHttpClient = OkHttpClient() init { retrofit = Retrofit.Builder() .baseUrl(Config.URL) .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) .build() } companion object { private val manager = AppClientManager() val client: Retrofit get() = manager.retrofit } } ``` 上述可看到兩行程式碼: ```Kotlin .addConverterFactory(GsonConverterFactory.create()) ``` 這邊是使用Google出的Json處理工具來進行轉換(Gson) ```Kotlin .client(ok