Null Pointer exception, Parcel.ReadException when sending SMS messages?

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 ...

+4
source share
4 answers

this can happen if the sms send number is empty.

0
source

I think the problem is codifying your lines ... The same problem is here. I am testing and I am not getting an error when I send a simple string as "asadsdasd"

0
source

I came across a similar error when I tried to use a test product for billing in an application, but my build project was not yet on the market.

I think the OS cannot bind your service. It happens that the service you use is os-based for the contact information, but the service you are trying to use cannot be reached, really.

0
source

I found another reason to get this message. If you use non-ascii characters in your message (e.g. U + 02BC), except that this NPE has also been reset.

0
source

All Articles