Code example for Handler

Methods: sendEmptyMessage

0
public class Settings extends Activity {
	private final Handler saveHandler 				= new Handler() { public void handleMessage(Message msg) { save(); }};
 
	public final Button.OnClickListener save = new Button.OnClickListener() {
        public void onClick(View v) { 
        	saveHandler.sendEmptyMessage(0); 
        } 
	}; 
 
	@Override 
	 public void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
	     setContentView(R.layout.settings);
 
	     setup(); 
	 } 
 
	 private void setup() { 
		 ((TextView) findViewById(R.id.host)).setText(NetworkUtil.hosturl != null ? NetworkUtil.hosturl : getString(R.string.baseurl));
 
		 findViewById(R.id.save).setOnClickListener(save);