【问题标题】:How to detect Restfull APIs are getting called in android?如何检测在 android 中调用 Restful API?
【发布时间】:2018-09-01 23:07:06
【问题描述】:
我正在开发一个库,我需要在其中确定 API 何时被调用并完成。 Ex 需要检查登录、注销、用户详细信息等 API 调用。
库应该自动检测 API 调用。不考虑网络库用于 API 调用..(Retrofit, Volley, HTTPClient..etc)。
是否有任何事件可用于检测 API 调用。
【问题讨论】:
标签:
android
android-studio
android-volley
retrofit
httpclient
【解决方案1】:
也许,您正在寻找这个库 -> okhttp logging interceptor,一旦正确安装,它将在 Logcat 中打印与您的网络通信相关的所有内容:发送的请求、检测 API 调用、超时、错误等。它集成得很好使用Retrofit,可能还有您提到的其他库。
此外,您可能想尝试 Android Studio 中的内置工具 -> Network Profiler(Android Profiler 中的 Network 选项卡)。在那里,您还可以以更直观的交付方式(图形和表格)检测 API 调用和网络