Android Logging Strings with newline or <br>
2 answers
The arguments to the methods in the Log class are Java strings, so escaping special characters is similar to Java. For instance,
String text = "String\nString"; Log.d("TEST!!", text); You'll get:
D/TEST!!īš String String a
String text = "String\\nString"; Log.d("TEST!!", text); will provide you with:
D/TEST!!īš String\nString in logcat.
As far as <BR> , I do not see the same effect as you. In particular,
String text = "String<br>String"; Log.d("TEST!!", text); It produces:
D/TEST!!īš String<br>String Therefore, I can not reproduce your current problem. However, in general, special characters in log lines are escaped in the same way as any other Java line. The logger is mute and there are no settings for automatically exiting special characters; you will have to do it yourself for arbitrary strings. Log methods just expand and call println_native .
+6
I am using System.getProperty ("line.separator")
ArrayList<String> txts = new ArrayList<String>(); txts.add("aoeuaeou"); txts.add("snhsnthsnth"); String msg = TextUtils.join(System.getProperty("line.separator"),txts); Log.d(TAG, "Bla bla bla: "+ msg ); show in the magazine how
Bla bla bla: aoeuaeou snhsnthsnth +1