In my app I want to e-mail the log file content for debugging purposes. However, on an Android device newline characters (\n) show up as spaces and not real new-lines in the mail. (It works correctly on iPhones and in the simulator.) Can this be fixed or is there a workaround?
By the way, why does the simulator truncate the mail message text?
Edit: I just tested on a more recent tablet (2019 vs 2013) and the problem goes away.
Edit 2: Actually it depends on the e-mail client. Test case: create a Hello world project and change start() to:
public void start() {
if(current != null){
current.show();
return;
}
Form hi = new Form("Test log", BoxLayout.y());
Button b = new Button("Send log");
b.addActionListener((ActionListener) (ActionEvent evt) -> {
String text;
try {
byte[] read = com.codename1.io.Util.readInputStream(Storage.getInstance().createInputStream("CN1Log__$"));
text = new String(read);
} catch (IOException ex) {
text = ex.getMessage();
}
sendMessage("Log file", new Message(text), "");
});
hi.add(b);
log("line 1");
log("line 2");
hi.show();
}
Testing on a Samsung Galaxy Tab A 10.1 this gives:
1) using (Samsung) Email client:
[EDT] 0:0:0,33 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29
[EDT] 0:0:0,36 - line 1
[EDT] 0:0:0,39 - line 2
2) using (Google) Gmail client:
[EDT] 0:0:0,33 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29 [EDT] 0:0:0,36 - line 1 [EDT] 0:0:0,39 - line 2