1

I am using the (I guess) quite popular library from LoopJ (https://github.com/loopj/android-async-http) to make GET and POST requests. Everything if working fine, but when it comes to cookie-handling I got some errors. Occasionally the POST-Login request in my app fails for no reason. In that case, the onFailure-method of the POST request is called correctly:

        @Override
        public void onFailure(Throwable error, String content) {
            Log.e("custom onFailure POST", error.getMessage());
            cb.onTaskComplete("LOGIN_FAILED");
        }

The strange thing is, that both "Throwable error" and "String content" are NULL-objects. That makes it really hard to analyze to problem of logging the user in into my app. Can someone tell me, how to get the source of the failure? Are there other methods I can implement to get a better fail-repost from the request?

4

1 回答 1

0

最简单的方法是调试您的应用程序,在onFailure方法中放置一个断点。当它在该断点处停止时,查看调用堆栈以查找错误的来源。

此外,在您的方法中,您可以调用Thread.currentThread().getStackTrace()then 遍历数组StackTraceElement[]- 因此您可以将信息输出到您的日志(或标准输出等),这样您就不需要调试应用程序。

于 2013-01-22T15:54:05.150 回答