0
我创建更新接口
public interface UserService {
@GET(Constants.Api.URL_LOGIN)
Call<String> loginUser(@Query("email") String email, @Query("password") String pass, @Query("secret") String secret, @Query("device_id") String deviceid, @Query("pub_key") String pubkey, @Query("device_name") String devicename);
当活动我打电话
final Call<String> responce = service.loginUser(loginedt.getText().toString(), md5(passwordedt.getText().toString()), secret, device_id, pub_key, device_name);
responce.enqueue(new Callback<String>() {
@Override
public void onResponse(Response<String> response) {
if (response.code() == Constants.Status.ERROR_404) {
Toast.makeText(LoginActivity.this, getResources().getString(R.string.wrong_log_pass), Toast.LENGTH_LONG).show();
} else if (response.code() != Constants.Status.ERROR_404 && response.code() != Constants.Status.SUCCES) {
Toast.makeText(LoginActivity.this, getResources().getString(R.string.wrong_request), Toast.LENGTH_LONG).show();
} else {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
});
我得到错误 onFailure处 java.lang.IllegalStateException:期望一个字符串,但是BEGIN_OBJECT在第1行第2列路径$
通常这些类型的错误是因为GSON的返回不能从你的对象分析你的JSON。将您的模型发布给用户。让我们看看是否一切正确 – acostela
我不发布任何对象。仅查询@Query字符串 – androidAnonDev
我不确定100%,但我认为您需要实体类才能使用改进。原因是内部它使用Gson,如果你没有任何实体类Retrofit不知道如何解析POST,GET数据 – acostela