zoukankan      html  css  js  c++  java
  • 小知识库慢慢积累

    一、Timer中的schedule()方法

    timer.schedule(new TimerTask() { void run()},0,60*60*1000):

      第一个参数:new TimerTask(){ void run()}:实现run()方法,主要业务逻辑

      第二个参数:调用schedule()方法后,需要延迟这么长的时间才第一次执行run()方法,0表示无延迟,立即执行run方法

      第三个参数:第一次run()方法执行完成后,从第二次开始每隔多长时间再执行一次run()方法。

          60*60*1000:为一个小时

          3*60*1000:为三分钟

    注意:

      schedule(TimerTask task, long delay):表示延迟delay毫秒时间后再执行task,没有得到重复执行,只执行一次

      schedule(TimerTask task, long delay, long period):表示延迟delay毫秒后重复的执行task,执行周期是period毫秒,重复执行

    二、Android获取后台服务Get Running Service 

      mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE):获得ActivityManager服务的对象 

      getRunningServiceInfo():获得正在运行的Service信息 

      Collections.sort(serviceModelList, new comparatorServiceLabel()):对集合排序 

      List<ActivityManager.RunningServiceInfo> runServiceList = mActivityManager .getRunningServices(defaultNum):获取系统所有正在运行的进程,defaultNum是设置一个默认service的数量大小

  • 相关阅读:
    HTML5响应式导航
    草原图片大全
    草原psd素材
    仿堆糖图片自滚动瀑布流效果
    夏日户外风景PSD素材
    国画经典之梅花PSD素材
    更改VS的运行主窗体
    在VS中如何更换项目名称
    如何使用Visual Studio 2008(VS2008)编译C语言
    #region 私有字段
  • 原文地址:https://www.cnblogs.com/hh8888-log/p/10040879.html
Copyright © 2011-2022 走看看