错误:java.lang.IllegalStateException: TimerTask is scheduled already
Process: com.multak.cookaraclient, PID: 27384
java.lang.RuntimeException: Unable to resume activity {…….MainActivity}: java.lang.IllegalStateException: TimerTask is scheduled already
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3139)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1420)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by: java.lang.IllegalStateException: TimerTask is scheduled already
at java.util.Timer.scheduleImpl(Timer.java:569)
at java.util.Timer.scheduleAtFixedRate(Timer.java:525)
at com.multak.cookaraclient.MainActivity.onResume(MainActivity.java:453)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1266)
at android.app.Activity.performResume(Activity.java:6446)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3129)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3170)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1420)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:150)? at android.app.ActivityThread.main(ActivityThread.java:5621)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)?
@Override
protected void onResume() {
super.onResume();
if(timerTask==null){
timerTask = new TimerTask() {
@Override
public void run() {
}
};
timer.scheduleAtFixedRate(timerTask, 100, 1000);
}
// timer.scheduleAtFixedRate(timerTask, 100, 1000);
}
一个TimerTask 通过schedule方法使用之后,不能通过schedule方法被调用第二次,如出现则报错误如上。。
如想利用这个timertask时,只能重新获得一个实例
错误:java.lang.IllegalStateException: TimerTask is scheduled already的更多相关文章
- android TimerTask 的简单应用,以及java.lang.IllegalStateException: TimerTask is scheduled already错误的解决方法【转】
Android应用开发中常常会用到定时器,不可避免的需要用到 TimerTask 定时器任务这个类下面简单的一个示例演示了如何使用TimerTask这个示例演示了3秒未有触屏事件发生则锁屏(只是设置下 ...
- Spring Scheduled定时任务报错 java.lang.IllegalStateException: Encountered invalid @Scheduled method 'xxx': For input string: "2S"
报错信息如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ding ...
- 集成JUnit测试错误java.lang.IllegalStateException: Failed to load ApplicationContext
1 详细错误信息 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.t ...
- Spring Boot整合Mybatis出现错误java.lang.IllegalStateException: Cannot load driver class:com.mysql.cj.jdbc.Driver
错误描述: Caused by: java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver ...
- SpringBoot测试类启动错误 java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
报错 java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Cont ...
- 安卓java.lang.IllegalStateException: The specified child already has a parent.解决方案
在使用ViewPager的时候遇到一个错误java.lang.IllegalStateException: The specified child already has a parent. You ...
- java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content&q ...
- java.lang.IllegalStateException:Web app root system property already set to different value 错误原因及解决 Log4j
Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件.甚至是套接口 服务器.NT的事件记录器.UNIX Syslog守护进程等: ...
- 访问tomcat出现java.lang.IllegalStateException No output folder错误解决方法
访问tomcat出现java.lang.IllegalStateException: No output folder错误解决方法 问题:tomcat分为安装版和解压缩版,解压缩版如果解压到安装盘,在 ...
随机推荐
- WinAPI使用: 时间,线程,中断
(1):C/C++获取当前系统时间:http://www.cnblogs.com/mfryf/archive/2012/02/13/2349360.html 不过当计算算法耗时的时候,不要忘记seco ...
- 06《UML大战需求分析》之六
不知不觉中,大多数课程的学习已经接近了尾声,<UML大战需求分析>这本书也陪伴了我们很久.在学习的过程中,我发现很多课程中其实都离不开UML.足以证明,UML在需求分析中的重大作用和在我们 ...
- (转)shiro权限框架详解03-shiro介绍
http://blog.csdn.net/facekbook/article/details/54893740 shiro介绍 本文正式进入主题.本文将介绍如下内容: 什么是shiro 为什么需要学习 ...
- MongoDB_基本操作
数据库操作 增加数据库 use db1 #如果数据库不存在,则创建数据库,否则切换到指定数据库 查询数据库 show dbs #可以看到,我们刚创建的数据库db1并不在数据库的列表中,要显示它我们需要 ...
- hibernate简单集合映射和获取
简单集合映射(可以直接获取) // javabean设计 public class User { private int userId; private String userName; // 一个用 ...
- python实现定时发送消息
#!/usr/bin/env python#-*- coding:utf-8 -*- @Author : wujf @Time:2018/8/21 15:59# 自动发送消息from threadin ...
- jquery ajax 全介绍
下面是Jquery中AJAX参数详细列表: 参数名 类型 描述 url String (默认: 当前页地址) 发送请求的地址. type String (默认: "GET") 请求 ...
- NOIP2016 DAY2 T1 组合数问题
题目描述 组合数表示的是从n个物品中选出m个物品的方案数.举个例子,从(1,2,3) 三个物品中选择两个物品可以有(1,2),(1,3),(2,3)这三种选择方法.根据组合数的定 义,我们可以给出计算 ...
- XPath语法简明介绍
简介: XPath 是一门在 XML 文档中查找信息的语言.XPath 用于在 XML 文档中通过元素和属性进行导航. XPath 路径表达式: XPath 使用路径表达式来选取 XML 文档中的节点 ...
- Python Django log日志
log日志 log开发日志 一.创建项目 1.python -m venv ll_env # 创建虚拟环境 2.source ll_env/bin/activate # 激活虚拟环境 3.pip in ...