0

I am making an SMS Android Application and currently have 2 activities : the main activity with the conversation list, and a second displaying the messages of a conversation.

Now I am trying to receive messages, and my BroadcastReceiver works well, but I really don't know how to handle the message then : how can I know if I am in the main activity and have to test if a new conversation is started (for example) or if I am in a conversation and have to update my message list.

I have tried with a booleans representing whether the activity is active or not but it is not working very well and seems to be ugly.

Help please, thank you ! :D

Dayan42
  • 1
  • 1
  • You can have a dedicated `Broadcast Receiver` class and then when it receives, it may broadcast the relevant information to receivers registered in your activity specifically for this task. However, other schemes might also work but, I need more info regarding the flow and functionality of the app. – Shaishav Aug 29 '16 at 16:05
  • I didn't really understood the "broadcast the relevant information to receivers registered in your activity" part, did you mean that I have to declare a broadcastreceiver variable in each class or create broadcasts as inner classes ? For the functionality : when a message is received, I can update the list of messages with a static class from my main activity, but in order to refresh the list of conversations for example, I have to call the refresh conversations function, but if I am currently in a conversation and NOT in the main activity, I get errors and the app crashes – Dayan42 Aug 29 '16 at 16:10
  • Yeah..something like that. A separate class for listening and parsing for SMS and then it can 'broadcast' the information to your other classes. – Shaishav Aug 29 '16 at 16:13

0 Answers0