如何在BasicNameValuePair中放置\ n值或左(新行)

时间:2012-10-04 10:00:15

标签: android http android-webview

我想发送带有许多新行或一些粗体文本或带有一些超链接的消息

例如:下面是我的代码

  List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
  String model = Build.MODEL + ",  " + Build.MANUFACTURER;
  nameValuePairs.add(new BasicNameValuePair("message", "Your Last Alert:  On "+mDate+" at "+mTime+", "+ model +" reported that its battery level was down to "+batteryLevel+". You might want to get it on a charger before it's too late! &nbsp;&nbsp Do you know where "+model+" is? </br></br> Click "+s+" to view in Google Maps.\n To find "+model+" with the Last Alert app on Android-phone, click here. \n\n\n\n\n\n Last Known Location : \n San Francisco California United States 94108"+"\n\n\n\n\n GPS Coordinates \n"+lat+", "+lon+"Altitude\n"+alt+"\n\nLocation Accuracy"+"16.40ft Diameter"));

我使用了&nbsp;用于空间,<br>用于新行\n用于新行,但问题是仅在纯文本中发送的消息(我已经在gmail中发送了邮件)这是我的帐户) 如下所示

 Your Last Alert: On 10/04/2012 at 03:23 pm, LG-P500, LGE reported that its battery level was down to 100. You might want to get it on a charger before it's too late!  &nbsp Do you know where LG-P500, LGE is? Click https://maps.google.com/maps?q=0.0,0.0 to view in Google Maps. To find LG-P500, LGE with the Last Alert app on Android-phone, click here. Last Known Location : San Francisco California United States 94108 GPS Coordinates 0.0, 0.0Altitude -1.79769313486231E308 Location Accuracy16.40ft Diameter

2 个答案:

答案 0 :(得分:2)

猜测..尝试将“</br></br>”替换为“<br/><br/>”。这可以解决您的问题。

答案 1 :(得分:1)

  1. 您是否在以下位置设置了“内容类型”(在http请求的标头中): text/html
  2. 将您的邮件包裹在<html>
  3. 使用<br/>代码而不是\n