java - Android : SMSManager - Attempt to get length of null array -
this question has answer here:
- what nullpointerexception, , how fix it? 12 answers
i have bug smsmanager when try send message method sendtextmesasge
. returns me java.lang.nullpointerexception: attempt length of null array
.
there code :
// constructs message telephonymanager mtelephonymgr = (telephonymanager) getsystemservice(context.telephony_service); string myphonenumber = mtelephonymgr.getline1number(); string destnumber = taskmanager.gethelpcenternumber(); string message = getresources().getstring(r.string.call_me_message) + " " + myphonenumber+"."; // sends message smsmanager smsmanager = smsmanager.getdefault(); smsmanager.sendtextmessage(destnumber, null, message, null, null);
the logcat receives message :
08-03 09:59:10.548: e/androidruntime(19825): fatal exception: main 08-03 09:59:10.548: e/androidruntime(19825): process: com.solarsquareretailer.view, pid: 19825 08-03 09:59:10.548: e/androidruntime(19825): java.lang.nullpointerexception: attempt length of null array 08-03 09:59:10.548: e/androidruntime(19825): @ android.os.parcel.readexception(parcel.java:1546) 08-03 09:59:10.548: e/androidruntime(19825): @ android.os.parcel.readexception(parcel.java:1493) 08-03 09:59:10.548: e/androidruntime(19825): @ com.android.internal.telephony.isms$stub$proxy.sendtext(isms.java:1428) 08-03 09:59:10.548: e/androidruntime(19825): @ android.telephony.smsmanager.sendtextmessage(smsmanager.java:305) 08-03 09:59:10.548: e/androidruntime(19825): @ com.solarsquareretailer.view.mainactivity.onoptionsitemselected(mainactivity.java:245)
found destnumber null , not correct (not phone number). it's why have java.lang.nullpointerexception.
Comments
Post a Comment