问题
I have an app where I need to be able to send SMS messages. I have the code to send them directly, but I would like to give the option to use Google Voice to users who don't have messaging plans. Does anyone know how to do this? I can't seem to find the way. Here is the way I am doing it now:
StringBuffer buffer = new StringBuffer();
buffer.append("GEOC ");
buffer.append(mLogType.getSelectedItemPosition() == 0 ? "@" : "x");
buffer.append(mGeocache.getWaypoint()).append(" ");
if(mLogEdit.getText().length() > 0)
{
buffer.append(mLogEdit.getText().toString());
}
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("41411", null, buffer.toString(), null, null);
回答1:
You want to use an SMS Intent.
That will give the user the option to select (or skip this step if he already have a default option) which SMS sending utility he want's to use.
several applications register themselves as such, such as skype, yahoo hub, google voice, etc.
So using a Intent, you tell android to use whatever the user wants to send the text message to a sms recipient.
回答2:
It's my belief that the user must have a google voice account setup and have the voice app installed. Then when you fire an intent to send an sms it will be their preference to use google voice or not.
回答3:
I've found a site where they've written their own google voice java library that you can import into your app and use. I just downloaded it yesterday so can't help with specific yet, but go ahead and take a look. It looks really promising.
http://code.google.com/p/google-voice-java/
来源:https://stackoverflow.com/questions/4338001/sending-an-sms-using-google-voice