Android中的Timer一般像下面這樣寫:
java代碼:
Timer timer = new Timer( );
TimerTask task = new TimerTask( ) {
public void run ( ) {
Message message = new Message( );
message.what = 1;
handler.sendMessage(message);
}
};
final Handler handler = new Handler( ) {
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
log.e("Timer","Timer");
update( );
break;
}
super.handleMessage(msg);
}
};
protected void onDestroy ( ) {
if (timer != null) {