protected void onCreate(Bundle savedInstanceState) {`
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.test_button);
button.setText("before");
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
button.setText("after");
}
}, 2000);
}
I think this solution will not cause a memory leak. According to the answer which gets most votes (How to pause / sleep thread or process in Android?),this will cause a memory leak. what do you think?