search

Home  >  Q&A  >  body text

android - 请求网络接口失败时的提示,能不能写在一个共用的文件里,不用每个请求接口下面都引用,只要监测到请求接口失败,就自动调用

请求网络接口失败时,会给出一个失败提示,需要在每个接口下面都写一遍吗,还是有没有办法写在一个共用的文件里,不用每个请求接口下面都引用,只要监测到请求接口失败,就自动调用

黄舟黄舟2772 days ago431

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 17:35:38

    Because the failure handling action for each request is different, the person who wrote the library cannot judge whether you want to perform the same failure handling. For the sake of generality, it should be written like this.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 17:35:38

    Just wrap a class to share it

    reply
    0
  • Cancelreply