retrofit请求直接返回string

1.添加gradle依赖:

compile com.squareup.retrofit2:converter-scalars:2.0.0'
2.更换转换器
mRetrofit = Retrofit.Builder()
                .baseUrl(HttpAddress.SITE)
                .addConverterFactory(ScalarsConverterFactory.create())
                .build();
3.定义返回类型为string

new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, retrofit2.Response<String> response) {
                Log.d("debug", response.body());
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {

            }
        }






猜你喜欢

转载自blog.csdn.net/nshzzu130/article/details/51819362
今日推荐