Okhttp3 onFailure检测

发布于 2025-01-31 20:09:32 字数 540 浏览 1 评论 0原文

我输入OKHTTP(OKHTTP3)以从服务器检索数据。如果从服务器检索信息的过程以“ onfailure”结尾,我想澄清为什么该过程以“ onfailure”结束。我如何确定域是否与服务器断开(服务器为下降,域没有服务器)或用户的Internet打开?在启动OKHTTP3之前,如何在onfailure上进行此操作,而不是在互联网上检查Internet,然后启动OKHTTP3进程?我想相应地发出相应的敬酒消息。

onfailure:

client.newCall(request).enqueue(new Callback () { 
@Override 
public void onFailure (Call call, IOException e) {
e.printStackTrace ();
}

如何:

  • 互联网不起作用
  • 域问题
  • 我可以诊断onfailure中的问题并显示相应的对话框?

I entered Okhttp (okhttp3) to retrieve data from the server. If the process of retrieving information from the server ends with "onFailure", I want to clarify why the process ends with "onFailure". How can I find out if the domain is disconnected from the server (the server is down‚ the domain is without a server) or the user's Internet is on? How can I do this on onFailure instead of checking the internet before starting okhttp3 and then starting the okhttp3 process? I want to issue a corresponding Toast message accordingly.

onFailure:

client.newCall(request).enqueue(new Callback () { 
@Override 
public void onFailure (Call call, IOException e) {
e.printStackTrace ();
}

how to:

  • The internet doesn't work
  • Domain problem
  • other...
    Can I diagnose problems in onFailure and show a corresponding dialog?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文