| import retrofit2.Retrofit; |
| import retrofit2.converter.gson.GsonConverterFactory; |
| |
| public class RetrofitClient { |
| private static Retrofit retrofit = null; |
| |
| public static Retrofit getClient(String baseUrl) { |
| if (retrofit == null) { |
| retrofit = new Retrofit.Builder() |
| .baseUrl(baseUrl) |
| .addConverterFactory(GsonConverterFactory.create()) |
| .build(); |
| } |
| return retrofit; |
| } |
| } |
最后,举行网络请求: