2014-03-26 34 views
0

我正在开发一个Android应用程序,它必须根据接收和处理某些服务器响应更新它的UI,我正在使用runOnUiThread。我在该应用中有五项活动,一切都工作得很好,但需要我重新启动活动(如去另一个然后返回它)或与它进行交互为了更新发生,那是我使用的所有活动,包括受感染的一个方式:什么可能会阻止Android中的UI按时更新?

runOnUiThread(new Runnable() { 
     public void run() { 
      try { 
       response_received(response); 
       } catch (Exception e) { 
       e.printStackTrace(); // never catch any Exceptions 
       } 
      } 
     }); 

private static void response_received(JSONObject response) throws Exception{ 

try { 
    int volume_setted = response.getInt(volume); 
    Normal_Activity.volume_value.setText(String.valueOf(volume_setted)); // the Volume TextView updated efficiently 
    Infected_Activity.volume_value.setText(String.valueOf(volume_setted)); // has the problem mentioned above 
    } catch (JSONException ex) { 
    } 
} 

我敢肯定,这个问题是不是在TextView的所有活动UI有这个问题,但我只是张贴了例。

+0

请加logcat的日志,这样的话很容易弄清楚 –

+0

@ ChaturaDilanPerera在Logcat中没有任何内容,正如我上面提到的那样,Exception从不会抛出,并且当我试图在最后一行之后打印日志消息以确保它已经到达时,消息成功打印。 – MRefaat

回答