Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在电子邮件中嵌入html表标记_Android_Html Email - Fatal编程技术网

Android 在电子邮件中嵌入html表标记

Android 在电子邮件中嵌入html表标记,android,html-email,Android,Html Email,我正在研究一个概念,在这个概念中,我必须在电子邮件正文中嵌入html表标记。我尝试了一些代码,它在2.2和2.3操作系统版本中运行良好,但相同的代码在最新的操作系统版本(如4.0等)中不起作用 我还尝试了Spannable和Html.fromHtml(),但它也不起作用 以下是我在2.2和2.3操作系统版本上的代码: //SEND EMAIL private void sendEmail(String imageUri) throws WriterException{ /

我正在研究一个概念,在这个概念中,我必须在电子邮件正文中嵌入html表标记。我尝试了一些代码,它在2.2和2.3操作系统版本中运行良好,但相同的代码在最新的操作系统版本(如4.0等)中不起作用

我还尝试了
Spannable和Html.fromHtml()
,但它也不起作用

以下是我在2.2和2.3操作系统版本上的代码:

//SEND EMAIL
    private void sendEmail(String imageUri) throws WriterException{
        //....................Prepare share email data............................. 
        int itemNumber=0;
        titleBuffer=new StringBuffer();

        titleBuffer.append("<html><body><table border="+"1"+"><tr border="+"0"+"><th>Item number</th>"+
                "<th>Barcode</th>"+"<th>Product name</th>"+"<th>Quantity</th></tr>");
        for(int i=0;i<_productList.size();i++){
            itemNumber=i+1;
            titleBuffer.append("<tr border="+"0"+"><td>"+itemNumber+"</td>"+
                    "<td>"+_productList.get(i).getProductBarcode()+"</td>"+"<td>"+_productList.get(i).getProductName()+"</td>"+
                    "<td>"+_productList.get(i).getProductQuantity()+"</td></tr>");

            /*titleBuffer.append("<tr border="+"0"+"><td>"+itemNumber+"</td>"+
                    "<td>"+_productList.get(i).getProductBarcode()+"</td>"+"<td>"+_productList.get(i).getProductName()+"</td>"+
                    "<td>"+_productList.get(i).getProductQuantity()+"</td>"+"<td>"+
                    "<img src="+"/'data:image/png;base64, "+generateBarcodeImage(GenerateBarcode.encodeAsBitmap(_productList.get(i).getProductBarcode(), 
                            BarcodeFormat.CODE_128, 600, 300))+"/'/></td></tr>");*/
        }

        titleBuffer.append("</table></body></html>");

        SpannedString bar = new SpannedString(titleBuffer.toString());

        if(_productList.size()==0){
            titleBuffer.append("NA");
        }
        //..........................................................................

        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("text/html");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Shopping List");
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,titleBuffer.toString());
        emailIntent.putExtra(Intent.EXTRA_STREAM, emailImageUri);
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    }
//发送电子邮件
private void sendEmail(字符串imageUri)引发WriterException{
//准备共享电子邮件数据。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
int itemNumber=0;
titleBuffer=新的StringBuffer();
标题buffer.append(“项目编号”+
“条形码”+“产品名称”+“数量”);
对于(int i=0;i请尝试以下代码:-

final Intent shareIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "The Subject");
shareIntent.putExtra(
Intent.EXTRA_TEXT,
Html.fromHtml(new StringBuilder()
    .append("<p><b>Some Content</b></p>")
    .append("<small><p>More content</p></small>")
    .toString())
);
final Intent shareIntent=新意图(Intent.ACTION\u SENDTO,Uri.parse(“mailto:”);
shareIntent.putExtra(Intent.EXTRA_主题,简称“主题”);
shareIntent.putExtra(
Intent.EXTRA_文本,
fromHtml(新的StringBuilder()
.append(“某些内容

”) .append(“更多内容

”) .toString()) );
有关更多信息,请参阅以下链接:-


这取决于处理它的电子邮件客户端。并非所有的电子邮件客户端都支持所有HTML标记。至少Gmail不支持它。它只适用于基本标记,如,
等。它不适用于特别是
标记

有关更多信息,请参阅这些so帖子


您尝试过Html.from()吗?是的,我尝试过,但没有效果。