TextViews not update in android UI

Ask by : fahad Idrees November 04, 2012 09:07

we have two activities one is where we make the connection via bluetooth and managing the blutooth other one is the update the UI where we want to update the GUI containing the TextViews. We successfully send and recieve the message within two activities and vice versa.

private OnMessageReceivedListener dataReceivedListener = new OnMessageReceivedListener() {
    public void OnMessageReceived(String device, String message) {
        Log.d("Message" , message);
        msg = message;


THE above function recieves the message and we did that successfully.

 private void UpdateGUI() {

 final Runnable myRunnable = new Runnable() {
    public void run() {  


The above function of connection class calls the method of our GUI class and send a recieved message to it.

In our GUI class we want this

    public void UpdateYoursBoard(String positions)
    Log.d("Positions" , positions);

}; we successfully recieved the message in log.d but when we want to change our textview text it gives following errors.

       at net.clc.bt.Board.UpdateYoursBoard(Board.java:3460) 

NOTE : we are working with bluetooth and we have 3 mobile connected simultaneously and UpdateYourBoard will change the TextViews of 3 mobiles GUI's.

kindly help me to fix the problem. Thanks in advance

View original question

Answer by : SnicolasNovember 04, 2012 09:00

First your Board class is far too big. 3 500 lines in a java file is very bad idea. Design more, decouple and split things. You are missing the divide and conqueer principle of IT.

In your case, tv is null. How and when do you get a reference to it ? If you used findViewById in your onCreate method (after super.onCreate has been called), it should work.

View original answer