0

I have a USSD service activity that handles ussd accessibility service calls and sends a broadcast. I also have several activities, each one makes a certain USSD call.

Should each activity implement its own broadcast receiver to process the reply and update the specific fields in the layout or is it better to have one broadcast receiver activity that handles replies and sends them to other activities?

Jilan
  • 89
  • 1
  • 2
  • 10
  • Good question, upvoted as i would like to know aswell ! – N.K Apr 06 '18 at 15:35
  • I would say rather than using separate receivers for each activity , one global receiver is preferable as it requires less amount of code, a central control where you have to take care of all the checks at one point. – MezzDroid Apr 06 '18 at 15:39
  • @MezzyDroid how would i customize each response and pass it accordingly to each activity? – Jilan Apr 06 '18 at 15:41
  • you can create callBacks for each activity and pass the response to respective activity accordingly ! – MezzDroid Apr 06 '18 at 15:42
  • @MezzyDroid i create a callback for each activity in the broadcast receiver activity? or a callback in each activity? – Jilan Apr 06 '18 at 17:29
  • You can make a single callback and that can be used anywhere ... in any activity ... – MezzDroid Apr 06 '18 at 17:32
  • @MezzyDroid i implemented a callback interface in the broadcast receiver class. I then passed it in the constructor function and initialized it from the activity. It worked fine! – Jilan Apr 09 '18 at 11:19
  • @MezzyDroid i still have one issue, when i run a ussd call by starting an intent, the ussd window shows above the activity while executing. After its done, the response is not shown and is caught directly by the broadcast receiver. How can i prevent the ussd window from showing at all?? – Jilan Apr 09 '18 at 12:09
  • @Jilan which response doesn't show ?? – MezzDroid Apr 09 '18 at 14:30
  • @MezzDroid it is all working fine i just want to hide the ussd window from showing above the activity when i call the ussd code. – Jilan Apr 10 '18 at 11:04
  • @Jilan This answer will help .... https://stackoverflow.com/questions/11453724/bring-my-activity-back-to-the-top – MezzDroid Apr 10 '18 at 18:40

0 Answers0