


That is, you can use the data model for whatever you want, if you change the views it won’t break the data model and vice versa. The beauty of using the Observer and Observable classes is that the data model, views and controller (the Activity that updates the views) are all separated.

The update() method is an obvious place to put your code which refreshes the views impacted by the changes in data, this is where the linkage between the views and the data model occurs (usually in the Android Activity). Refresh your Views in the update() Method When the data changes, the Observer is notified automatically and fires its update() method. By extending the Observable class on your data object (model), you are able to assign Observers which listen for changes in said data model. Two awesome example of this are the Java Observer and Observable classes. The beauty of using an object oriented language such as Java is the ability to extend other classes on your object. Log.d("ADDTOBUFFER", "(" + newBytes.length + ")" + mStringBuffer.toString()) įor(int i = 0 i < mStringBuffer.Extending the Android Observer and Observable Classes for Auto Updates Unfortunately, I do not have experience to know why or how to fix this issue. I have a thread on my main activity that should be constantly updating these values, and I believe it is somewhere here that I am having the problem.

it will update quickly for a bit, seem to hang, then update quickly again) The problem is that it seems to update the TextViews inconsistently, resulting in a little bit of a jerky performance (i.e. I have a log statement logging the data as it comes in, so I know that it is receiving it all. My app is to receive 3 values from an Arduino (which sends these values every 10ms) and update the three corresponding TextViews displayed on the screen. Hi, I am having some trouble developing an app for receiving serial data from an Arduino device.
