看一个例子:
先定义好接口
public interface APIInterface{
@GET("/admin/login")
Flowable<ResponseBody> getEntity(@Query("userName") String userName,
@Query("password") String password);
}
先看出问题的写法:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.0.2.2:8080")
.addConverterFactory(GsonConverterFactory.create())
.build();
APIInterface service = retrofit.create(APIInterface.class);
service.getEntity("aaa","123")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ResourceSubscriber