java - SmsManager sending message more than one -
i developing auto reply android application send messages incoming number, if matches selected number i.e. saved in database. running send message twice time, sends 3 messages incoming number.
i using following code:
void processcall(string innumber, string msg) { try { string sent = "android.telephony.smsmanager.status_on_icc_sent"; pendingintent pisent = pendingintent.getbroadcast(getbasecontext(),0, new intent(sent), 0); pendingintent pidel = pendingintent.getbroadcast(getbasecontext(),0, new intent("dilivered"), 0); smsmanager man = smsmanager.getdefault(); //arraylist<string> smstext = man.dividemessage(msg); man.sendtextmessage(innumber, null, msg, pisent, null); //man.sendmultiparttextmessage(innumber, null, smstext, null, null); toast.maketext(getbasecontext()," msg send " + innumber, toast.length_short).show(); contentvalues sentsms = new contentvalues(); sentsms.put(telephon_number_field_name, innumber); sentsms.put(message_body_field_name, msg); contentresolver contentresolver = getcontentresolver(); contentresolver.insert(sent_msgs_contet_provider, sentsms); return; } catch (exception e) { toast.maketext(getapplicationcontext(), "sms faild, please try again later!", toast.length_long).show(); e.printstacktrace(); }
where wrong? appreciated.
try putting in log messages in between , see how many times function getting executed. also, if service running, see if firing service multiple times
Comments
Post a Comment