我正在开发一个我必须使用 SMS 服务的应用程序。当我尝试发送短信时,出现以下奇怪的异常。有时 SMS 发送得非常好,但有时我会收到此异常。我不知道问题出在哪里。以下是我的代码:
String messageText = Util.getSMSText(myActivity.this, Util.CurrentLocation);
messageText += "http://maps.google.com/maps?q=" + locationInfo.getLat() + "," + locationInfo.getLng();
String number = guardian.getGuardianNumber();
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, text, null, null);
以下是跟踪:
12-22 21:03:59.325: W/System.err(8140): java.lang.NullPointerException
12-22 21:03:59.325: W/System.err(8140): at android.os.Parcel.readException(Parcel.java:1328)
12-22 21:03:59.325: W/System.err(8140): at android.os.Parcel.readException(Parcel.java:1276)
12-22 21:03:59.325: W/System.err(8140): at com.android.internal.telephony.ISms$Stub$Proxy.sendTextOnSubscription(ISms.java:1096)
12-22 21:03:59.325: W/System.err(8140): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:149)
12-22 21:03:59.325: W/System.err(8140): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:89)
12-22 21:03:59.335: W/System.err(8140): at com.invocode.sms.SMSManager.sendSMS(SMSManager.java:12)
12-22 21:03:59.335: W/System.err(8140): at com.invocode.ui.iamhere.myActivity$2$2.onClick(myActivity.java:205)
任何帮助表示赞赏...