android - Using PendingIntent to update the status of an fail sent message -


A user sends an SMS, if it is not sent for any reason, then it will be updated.

Note: We are using the provider "Content: // SMS /" to access the SMS repository.

SMS Sender Class

  ** Constructor ** Public SMSMax Message (Message Repository Message Repository, Thread Regressory Thread Respositive, Reference Reference) {This (Message Replayer, Thread Ripitzri) ; This.sentIntent = new intent (SmsMessageSender.SENT); This.sentPI = Pending .getBroadcast (Reference, 0, this.sentIntent, pendingIntent.FLAG_UPDATE_CURRENT); } @ Override Public Recording Message (String Receiver, String Content) {Long Thread ID = Thread Resorgetry. Get Or Cereal Truffed Rehearsant (Recipient); ArrayList & LT; String & gt; MessageParts = Generates message (content); SentIntent.putExtra ("Thread ID", Thread ID); SmsManager.sendMultipartTextMessage (recipient, blank, message pars, new Arrayists & lt;> (Arrays.asList (sentPI)), empty; Uri uri = Message Resository.Instant (new message (0, recipient, content, new date) , Blank, message status, reference, thread id, telephony, textured SMS column. STATUS_NONE)); SentIntent.putExtra ("messageUri", uri.toString ()); }  

activity

  @ override public at zero () {super.onResume (); SmsSentReceiver = New Broadcast Receiver () {@ Override Public Wide On Receive (Reference ARB0, Intent arg1) {if (GetResultCode ()! = Activity. RESULT_OK) {long threadId = arg1.getLongExtra ("threadId", -1); // TODO: Update SMS message with status failed} else {// TODO: SMS message updated with status breakthrough}}}; Register receiver (smsSentReceiver, new intent filter (SMSMSEZder. SENT)); }  

On the broadcast receiver in the onReiveive method on my activity, long thread id = arg1.getLongExtra ("threadId", -1); always gives -1 (the value entered in the Xtra is different from -1)

< P> You were additional sent is too late pendingIntent.getBroadcast () . By calling

Pending . >

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -