在代码中使用以下语句,将URL添加到HTTP请求的Log中:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(logging);
将以上代码添加到应用程序中的OkHttpClient Builder中,以便能够将HTTP请求的URL及其响应,显示在Logcat中。 此外,确保在Logcat窗口中将应用程序包名设置为Verbose(详细)级别,以便能够查看所有信息。
上一篇:AndroidStudio的Live-Edit功能出错:检测到多个minApi。
下一篇:AndroidStudio的MainActivity.kt无法在main_activity.xml中引用ids。