retrofit请求直接返回string

来源:互联网 发布:mahout算法库 编辑:程序博客网 时间:2024/06/05 03:12
1.添加gradle依赖:compile com.squareup.retrofit2:converter-scalars:2.0.0'2.更换转换器mRetrofit = Retrofit.Builder()                .baseUrl(HttpAddress.SITE)                .addConverterFactory(ScalarsConverterFactory.create())                .build();3.定义返回类型为stringnew 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) {            }        }


1 0
原创粉丝点击