【发布时间】:2014-08-07 05:39:04
【问题描述】:
所以这是我的问题。
我有一个计时器,它应该每 X 秒发送一条短信。 我希望短信成为用户当前的 GPS 位置。 所以,我想发送一种谷歌地图 URL,使用我得到的 GPS 坐标,并为地图添加一些标记、地图类型、大小......。
为此,我需要在 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 永远不会发送。当我删除包含“&”的每个部分时,它工作正常。
我尝试使用“&”代替 ”&”。还是不行。
这是我的短信管理员发送短信:
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);
有什么想法吗?
谢谢!
【问题讨论】:
-
感谢您的链接!它对我很有帮助。地址的编码是强制性的。添加一些 '&' 打破 url。