我用来发送位置的格式是利用maps.google.com网站,例如:
"http://maps.google.com/maps?q=" + loc_x + "," + loc_y + "&iwloc=A"
此字符串可以插入SMS或电子邮件消息中.我发现this site有一些很好的信息,用于格式化URL以自动打开以给定坐标为中心的地图. SMS的可能实现可能是:
String message =
"http://maps.google.com/maps?q=" + loc_x + "," + loc_y + "&iwloc=A";
private void sendSMS(String phoneNumber, String message){
SmsManager sms = SmsManager.getDefault();
Log.d(TAG, "Attempting to send an SMS to: " + phoneNumber);
try {
sms.sendTextMessage(phoneNumber, null, message, null, null);
} catch (Exception e) {
Log.e(TAG, "Error sending an SMS to: " + phoneNumber + " :: " + e);
}
}
其中loc_x和loc_y表示来自LocationManager实例的lat和lon.