【发布时间】:2015-04-24 22:46:48
【问题描述】:
当我想从 TextView 中获取文本并将其像文本一样放入 Intent 时,我收到“失败的 Binder 事务错误” 对于小文本,它可以正常工作,我可以正确获取文本,并且在我的邮件应用程序中有它之后。
有什么方法可以将文本从我的 TextView 放入邮件应用程序中的任何大小? 您何时以及如何跟踪文件并确保它们已被删除并且不会向设备发送垃圾邮件。该解决方案的设计是什么?
下面是我的代码,它适用于少量文本..
private void sendLogMail() {
try {
if ("".equals(logTextView.getText().toString().trim())) {
Toast.makeText(getApplicationContext(), "Sorry, no log information to send", Toast.LENGTH_LONG).show();
}
else {
String[] mailReceiver = new String[] { getString(R.string.logviewer_mailto)};
startActivity( Intent.createChooser(
new Intent(Intent.ACTION_SEND).setData(Uri.parse("mail:to")).setType("text/plain")
.putExtra(Intent.EXTRA_EMAIL, mailReceiver)
.putExtra(Intent.EXTRA_SUBJECT, "Log: " + Utils.formatReadableTimestamp( System.currentTimeMillis()))
.putExtra(Intent.EXTRA_TEXT, getInfo() + "\n" + "\n" + "Log: "+ "\n"+logTextView.getText()),
"Please config your mail account") );
}
}
catch (Exception e) {
getLog().error("Error sending logfile as email", e);
}
}
private String getInfo() throws Exception {
return new StringBuilder()
.append("Terminal ID: " + getCore().getID())
.append("\n")
.append("License ID: " + getCore().getLicense())
.append("\n")
.append("Outlet ID: " + getCore().getOtherID())
.append("\n")
.append("Name: "+" "+getLoggedIn().getFormattedName())
.append("/")
.append(" ")
.append(getLoggedIn().getId())
.toString();
}
}
【问题讨论】:
标签: android performance email android-intent android-activity