0
1 분마다 활동을 다시로드하려고합니다. 나는이 핸들러를 사용하여 시도했다. 그러나 문제는 내가 장치의 키를 누를 때, 멈추지 않고 무한 루프로 들어간다는 것이다 ..2 분 간격으로 활동 다시로드
여기는 내가 작성한 코드이다.
public class Chat extends Activity {
Handler handler;
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
setContentView(R.layout.chat);
handler = new Handler();
Toast.makeText(getApplicationContext(), "again", 400).show();
doTheAutoRefresh();
}
private void doTheAutoRefresh() {
handler.postDelayed(new Runnable() {
public void run() {
Intent intent = getIntent();
startActivity(intent);
finish();
//doTheAutoRefresh();
}
}, 10000);
}
public void onPause() {
super.onPause();
}
}
당신은 단지 데이터를 새로 고치시겠습니까? – Luke
채팅하는 경우 매분마다 서버를 폴링하지 마십시오. 소켓에 대해 읽으면 일부 푸시 솔루션 (GCM)을 사용하여 앱에서 콘텐츠를 업데이트 할 수 있습니다. –