I read a little about the exception that is thrown when using the BaseAdapter, but I cannot find an alternative solution:
Make sure the contents of your adapter are not changed from the background thread
What I want to achieve is to keep a copy of the message queue in memory and use this message queue to populate the BaseAdapter for my ListView. The reason for this is that the message queue will continue to receive messages from the socket, even if the ListView is not present at the moment (for example, the chat window).
The problem occurs when I have an Activity with a ListView in the foreground, a BaseAdapter tied to message queue data, and a message appears in the socket. Adding a new message to the queue will raise the exception mentioned above. If I had not pre-fill your BaseAdapter in the message queue (as in the base adapter, which has its own message queue), and updating both of them when a new message arrives, I can not find a way to this question.
I really don't want to redouble my efforts to maintain these two queues this way, of course, is there a better way to do this? Sending broadcast messages does not work either because of a potential delay in the adapter that services scrolling and in the call to notifyDataSetChanged.
source
share