在 Logcat 上显示更多字符串 [英] Displaying More string on Logcat

查看:52
本文介绍了在 Logcat 上显示更多字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个使用JSON"作为服务器响应的 Android 应用程序.通常我处理 JSON 响应.但是现在我遇到了logcat的问题,如果 JSON 响应字符串很长,超过 x 个字符(我不知道 logcat 可以显示的最大字符串到底有多少),则缺少一些 JSON 字符串.

I am currently working on an android App that uses 'JSON' as response from server. Usually I work on the JSON response. But now I have a problem with logcat, if the JSON response string is very long , more than x character (i don't know exactly how much is the max string that could be displayed by logcat), some of the JSON string is missing.

虽然它仍然可以给我输出,但我需要关于从服务器传输的 JSON 字符串的信息.

Although it still could give me the output, I need the information on the JSON string that is transmitted from the server.

是否有可能在 logcat 上显示更多字符串?就像增加缓冲区或任何我可以用来增加 logcat 可以显示的最大字符串长度的参数一样.

Is there any possibility to display more string on logcat? Like increasing the buffer or any parameter that I could use to increase the maximum string length that could be displayed by logcat.

推荐答案

丑陋但有用:

public static void longInfo(String str) {
    if(str.length() > 4000) {
        Log.i(TAG, str.substring(0, 4000));
        longInfo(str.substring(4000));
    } else
        Log.i(TAG, str);
}

这篇关于在 Logcat 上显示更多字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆