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的数量大小

  • 相关阅读:
    p2psearcher绿色版使用方法
    P2PSearcher云点播设置和使用技巧
    怎么看电脑有没有安装USB3.0驱动
    USB3.0驱动与2.0有什么区别
    win7 64位 安装java jdk1.8 ,修改配置环境变量
    jdk是什么?jdk1.8安装配置方法
    adb工具包究竟能帮我们做什么?
    web.xml中load-on-startup有和用处
    Spring Aop
    Struts2中的properties文件详解
  • 原文地址:https://www.cnblogs.com/hh8888-log/p/10040879.html
Copyright © 2011-2022 走看看