0

I have an instance of object A that has a accumulator and a BroadcastReceiver that will increment the accumulator.

I have an IntentService that receives the object A as a parcel in the intent, sends the value via the SmsManager and when the "sent" pendingIntent calls back the the broadcast receiver of A will increment the accumulator of A.

This should work but I can't find a way to add the BroadcastReceiver to the parcel. Is it possible? Or is there some workaround?

DennisVDB
  • 1,347
  • 1
  • 14
  • 30
  • honestly, i dont completely understand your control flow, what exactly do you want to achieve? – pskink Oct 25 '14 at 07:36
  • I have an object A with an accumulator, I send the value of the accumulator in an sms, and when the SMSManager tells me the message has been sent I increment the accumulator. And I do this for multiple instances of the object A. – DennisVDB Oct 25 '14 at 07:38
  • so use a singleton pattern, or I'm missing something? – pskink Oct 25 '14 at 07:46
  • No, all the instances are independent. If I send N messages with the accumulator of A1 and M messages with the accumulator of A2. A1 should be incremented N times and A2 M times. For this I need to know when I receive "message was sent" callback to which object it is meant for. Therefore the idea of the object itself owning a BroadcastReceiver. – DennisVDB Oct 25 '14 at 08:00
  • if you are using SmsManager.sendTextMessage there is a PendingIntent sentIntent parameter, you can pass a "key" in its Intent to be used in your BroadcastReceiver to find the correct accumulator? – pskink Oct 25 '14 at 08:09
  • Do you mean the "requestCode" in PendingIntent.getBroadcast(...)? – DennisVDB Oct 25 '14 at 09:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/63624/discussion-between-dnx-and-pskink). – DennisVDB Oct 25 '14 at 09:12

0 Answers0