I am working on an application in which I want to use the SMS service. When I try to send an SMS, I get the following strange exception. Sometimes an SMS is sent absolutely normal, but sometimes I get this exception. I do not know where the i8es problem is. Below is my code:
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);
The following is the track:
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)
Any help is appreciated ...
source share