私はポストのための改修を実施する際に、このフォーマットAndroidの改修簡単なチェックと印刷結果
{"result":"1"}
でサーバーとプリント結果によって確認されたuserMobileNumber
を投稿し、私はNo Retrofit annotation found
エラー
チェックモバイルモデル:
public class CheckMobile {
private String userMobileNumber;
public String getUserMobileNumber() {
return userMobileNumber;
}
public void setUserMobileNumber(String userMobileNumber) {
this.userMobileNumber = userMobileNumber;
}
}
サービス:
public interface TestService {
@POST("rst_checkmobile")
Call<CheckMobile> checkMobile(String body);
public static final Retrofit retrofit = new Retrofit.Builder()
.baseUrl(ClientConfigs.REST_API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
ポストと取得結果:
@OnClick(R.id.request_create_account)
public void RequestCreateAccount(View view) {
String userMobileNumber = user_mobile_number.getText().toString().trim();
if (userMobileNumber.length() > 1) {
TestService testService = TestService.retrofit.create(TestService.class);
final Call<CheckMobile> call = TestService.checkMobile(userMobileNumber);
call.enqueue(new Callback<CheckMobile>() {
@Override
public void onResponse(Call<CheckMobile> call, Response<CheckMobile> response) {
Log.e("OK: ", response.body().toString());
}
@Override
public void onFailure(Call<CheckMobile> call, Throwable t) {
Log.e("ERROR: ", t.getMessage());
}
});
}
}