gpt4 book ai didi

android - Retrofit 解析表单 Action 并在 webview 中显示

转载 作者:行者123 更新时间:2023-11-29 22:53:13 25 4
gpt4 key购买 nike

我知道如何调用网络服务但是我显然不知道如何解析它并将其放入 webview 中:

我目前正在使用改造

@GET(TOPUP_CREDITCARD+"/{id}"+"/{amount}")
Call<BaseResponse> topUpCreditCard(@Path("id") String id, @Path("amount") String amount);

enter image description here

更新:我无法解析数据,我不知道。响应是这样的:

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

我有这样的代码:

 final Call<BaseResponse> call = client.topUpCreditCard(SharePreferences.getUserId(context),"10");
call.enqueue(new Callback<BaseResponse>() {
@Override
public void onResponse(Call<BaseResponse> call, Response<BaseResponse> response) {
if (listener != null) {
listener.onProgressDismiss(response.message(), false);
}
if (response.isSuccessful()) {
if (response.body() != null) {
if (response.body().status == UriConstants.SUCCESSFULLY) {
Log.d("RESPONSE:",""+response.message());
//TODO ADDED LINIENT IN THE SERVICE, CHECK IF MIGHT EFFECT OTHER WS CALL
listener.onResult(response.message());// Log.d("RESPONSE:",""+response.body().message);

}
}
}
}

@Override
public void onFailure(Call<BaseResponse> call, Throwable t) {
Log.d("RESPONSE:",""+t.getMessage());
}
});
}

最佳答案

试试这个

 WebView wv = (WebView) findViewById(R.id.WebView01);        

final String mimeType = "text/html";
final String encoding = "UTF-8";
String html = "your response";


wv.loadDataWithBaseURL("", html, mimeType, encoding, "");

关于android - Retrofit 解析表单 Action 并在 webview 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57704708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com