Retrofit简单使用方法

String baseUrl ="http://10.0.2.2:80/ /";

Retrofit retrofit =newRetrofit.Builder()

.baseUrl(baseUrl)

.addConverterFactory(GsonConverterFactory.create())

.addCallAdapterFactory(RxJavaCallAdapterFactory.create())

.build();

RequestSerives requestSerives = retrofit.create(RequestSerives.class);

RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json;charset=UTF-8"), strEntity1);

Call call = requestSerives.getsignrequest(body);

call.enqueue(newCallback() {

public voidonResponse(Call call, Response response) {

System.out.println("响应成功:" );

}

public voidonFailure(Call call, Throwable t) {

System.out.println("响应失败:" );

});

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、


public interfaceRequestSerives {

@POST("applications.php")

Call getrequest(@BodyRequestBody strEntity); 

@POST("signactivity.php")

Call getsignrequest(@BodyRequestBody strEntity1);

}

你可能感兴趣的:(Retrofit简单使用方法)