text - SmsManager causes com.android.phone force closes randomly -
i using smsmanager send text messages application. code snippet is
smsmanager.sendtextmessage(number, null, content, null, null);
for messages less 160 characters. , multipart messages use,
arraylist<string> parts = smsmanager.dividemessage(content); sman.sendmultiparttextmessage(number, null, parts, null, null);
these statements cause process com.android.phone has stopped unexpectedly please try again in random fashion. don't understand what's going on.
this stack trace got:
java.lang.nullpointerexception e/androidruntime( 1143): @ com.android.internal.telephony.smsdispatcher.handlesendcomplete(smsdispatcher.java:741) e/androidruntime( 1143): @ com.android.internal.telephony.smsdispatcher.handlemessage(smsdispatcher.java:407) e/androidruntime( 1143): @ android.os.handler.dispatchmessage(handler.java:99) e/androidruntime( 1143): @ android.os.looper.loop(looper.java:123) e/androidruntime( 1143): @ android.app.activitythread.main(activitythread.java:4603) e/androidruntime( 1143): @ java.lang.reflect.method.invokenative(native method) e/androidruntime( 1143): @ java.lang.reflect.method.invoke(method.java:521) e/androidruntime( 1143): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) e/androidruntime( 1143): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) e/androidruntime( 1143): @ dalvik.system.nativestart.main(native method)
any pointers appreciated.
smsmanager.sendtextmessage(number, null, content, null, null);
technically null parameters sentintent , deliveredintent shouldn't cause problems. that's not case application. have seen many applications in android market same issue , users giving them 1 star rating. repaced null parameters insignificant intents , don't have trouble using them.
pendingintent sent = pendingintent.getbroadcast(context, 0, new intent(), 0); pendingintent delivered = pendingintent.getbroadcast(context, 0, new intent(), 0); smsmanager.sendtextmessage(number, null, content, sent, delivered);
now code works fine.
Comments
Post a Comment