【发布时间】:2020-08-23 00:51:48
【问题描述】:
在我的应用程序中,我想通过电子邮件发送日志文件内容以进行调试。但是,在 Android 设备上,换行符 (\n) 在邮件中显示为空格,而不是真正的换行符。 (它在 iPhone 和模拟器上都能正常工作。)这个问题可以修复还是有解决方法?
对了,为什么模拟器会截断邮件消息文本?
编辑:我刚刚在更新的平板电脑上进行了测试(2019 年对比 2013 年),问题就消失了。
编辑2:实际上它取决于电子邮件客户端。测试用例:创建一个Hello world项目并将start()改为:
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();
}
在三星 Galaxy Tab A 10.1 上进行测试:
1) 使用(三星)电子邮件客户端:
[EDT] 0:0:0,33 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29
[EDT] 0:0:0,36 - line 1
[EDT] 0:0:0,39 - line 2
2) 使用 (Google) Gmail 客户端:
[EDT] 0:0:0,33 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29 [EDT] 0:0:0,36 - line 1 [EDT] 0:0:0,39 - line 2
【问题讨论】:
标签: android email newline codenameone