zoukankan      html  css  js  c++  java
  • 定时器的简单实例

    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();
    }
    }

    };

  • 相关阅读:
    Sql优化思路
    「网络流随想随记」
    「ZJOI 的部分题解整理」
    「循环矩阵相关的一些东西」
    知识蒸馏
    3D Human Pose Estimation with 2D Marginal Heatmaps
    模型剪枝
    目标检测小网络
    selenium---解决clear方法失效
    selenium---快速跳转到指定元素
  • 原文地址:https://www.cnblogs.com/xingmeng/p/2541565.html
Copyright © 2011-2022 走看看