-1

我有一个这样的代码片段:

Log.i(tmpTag, "B4 URL CHANGE: URL in response = " + responseURL + ".\nLast URL = " + mLastUrl);    //SHOWN IN LOGCAT
if (m_CurrentEventName.contentEquals("forgotpassword")) {
mLastUrl = responseURL.replace("../../../", "");
} else if (m_CurrentEventName.contentEquals("tskstdlogin") &&     responseURL.indexOf("changepassword") != -1) {
mLastUrl = responseURL.replace("../../../", "");
} else {
mLastUrl = responseURL;
}

Log.i(tmpTag, "AFTER URL CHANGE: URL in response = " + responseURL + "\nLast URL = " + mLastUrl);    //NOT SHOWN IN LOGCAT

我期待两个日志语句,但只有第一个显示在 LogCat 中,如下所示:

 08-27 09:39:06.867: I/bindDataTask(1994): B4 URL LOOP: URL in response = "some internal url".
 08-27 09:39:06.867: I/bindDataTask(1994): Last URL = "some internal url".

知道为什么会这样吗?

4

1 回答 1

1

除了标签和优先级之外,Logcat 消息还包含许多元数据字段。您的第一条日志行已执行,因此已打印,但由于发生了一些异常而未打印其他日志消息,并且您的程序控制转到了 try-catch 块的捕获部分...

这里...

    try{
    Log.i(tmpTag, "B4 URL CHANGE: URL in response = " + responseURL + ".\nLast URL = " + mLastUrl);    //SHOWN IN LOGCAT

    ...
    ...
   // Exception occured..GOTO catch block
    ..
    Log.i(tmpTag, "AFTER URL CHANGE: URL in response = " + responseURL + "\nLast URL = " + mLastUrl);    //NOT SHOWN IN LOGCAT
    .....

    }catch(Exception e){
    Log.e("Exception here...",e.toString());
    }
于 2013-08-27T10:39:23.590 回答