使用 SmsManager 发送预先保存的消息(作为字符串)

Sending a pre-saved message (as a string) using SmsManager

我真的是 android 开发的新手,我经常被卡住。在我的应用程序中,我试图向用户指定的号码发送一条预先保存的消息。我能够使用 smsmanager 发送消息(基本教程帮助很大)但我希望程序发送用户已使用 gps 位置信息预先定义的消息。

我在 Strings.xml 文件中创建了一个字符串,但我无法从我创建的片段中访问该字符串。 那么基本上我怎样才能将预先写好的消息 + gps 信息发送到预先选择的号码? (号码和留言将由用户选择以备将来使用)

String stringineed =getString(R.string.nameofstringyourneedinstringsxml);
double latitude = location.getLatitude();
double longitude = location.getLongitude();
Geocoder gCoder = new Geocoder(context);
List<Address> addresses = null;
try {addresses = gCoder.getFromLocation(latitude, longitude, 1);
    } catch (IOException e) {
    e.printStackTrace();
    }
if (addresses != null && addresses.size() > 0) {
String addressinfo = "addresses.get(0).getAddressLine(0) + "\n"+ addresses.get(0).getPremises() + "\n"+ addresses.get(0).getCountryCode() + "\n"+ addresses.get(0).getPostalCode() + "\n""}
String prewrittenmessage =("This is the prewrittenmessage"+addressinfo);
//or stringinneed+""+ addressinfo
String phone = "some chosen number to be sent to";
Intent sendtoemail = new Intent(Intent.ACTION_SEND);
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phone, null, prewrittenmessage ,null, null);