private Timer timer = new Timer();
timer.schedule(task, 800);
TimerTask task = new TimerTask() {
@Override
public void run() {
intent = new Intent(LoadUI.this, LoadDataService.class);
Bundle bundle = new Bundle();
bundle.putString("city", WeatherUtil.getDefaultCity(LoadUI.this));
bundle.putBoolean("check", false);
intent.putExtras(bundle);
LoadUI.this.startService(LoadUI.this.intent);
while(true){
if( ResourceAdapter.getMessageCode() != 0 ){
handler.sendEmptyMessage(0);
break;
}
}
}
};
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
if( ResourceAdapter.getMessageCode() == Constant.NET_LINK_ERROR){
Toast.makeText(LoadUI.this, getString(R.string.net_error),
Toast.LENGTH_LONG).show();
}
if (ResourceAdapter.getMessageCode() == Constant.SUCCESS_FULL) {
timer.cancel();
Intent weatherIntent = new Intent();
weatherIntent.setClass(LoadUI.this, WeatherUI.class);
LoadUI.this.startActivity(weatherIntent);
LoadUI.this.stopService(intent);
LoadUI.this.overridePendingTransition(anim.slide_in_left, anim.slide_out_right);
LoadUI.this.finish();
}
}
};