短信中的&符号-发送Android短信

问题描述 投票:0回答:2

所以这是我的问题。

我有一个计时器,应该每X秒发送一次SMS。我想让短信成为用户当前的GPS位置。因此,我想使用我获得的GPS坐标发送一种Google Maps URL,并为地图添加一些标记,地图类型,大小...。]

为此,我需要在URL中使用字符“&”。为了得到这样的东西:http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&maptype=roadmap

(即:https://developers.google.com/maps/documentation/staticmaps/?csw=1#URL_Parameters

但是,当我要使用这种URL时,请在SMS的短信中使用“&”。 SMS永远不会发送。当我删除包含“&”的每个部分时,它工作正常。

我尝试使用“&”代替 ”&”。仍然不起作用。

这里是我的SMS管理员来发送SMS:

smsManager.sendTextMessage(INT, null, "Alert - RED AREA \n TIME :  " + current date + " \n  Lat: " + latitude + " \n Long: " + longitude + "Link Maps : http://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude +"&zoom=12&size=400x400&maptype=satellite", null, null);

上面的代码,不发送任何消息。但这确实做到了:

smsManager.sendTextMessage(INT, null, "Alert - RED AREA \n TIME :  " + current date + " \n  Lat: " + latitude + " \n Long: " + longitude + "Link Maps : http://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude, null, null);

任何想法?

谢谢!

所以这是我的问题。我有一个计时器,该计时器应该每X秒发送一次SMS。我想让短信成为用户当前的GPS位置。因此,我想发送一种Google Maps ...

android sms ampersand
2个回答
0
投票

最简单的解决方案是考虑使用某种special


0
投票

使用“%26”代替“&”或“&amp”,URL仍将解析并且SMS将正确构建]]

© www.soinside.com 2019 - 2024. All rights reserved.