实现服务运行小段时间后自己关闭
来源:互联网 发布:highwire press数据库 编辑:程序博客网 时间:2024/05/17 03:27
showNotification();
// Start up the thread running the service. Note that we create a
// separate thread because the service normally runs in the process's
// main thread, which we don't want to block.
Thread thr = new Thread(null, mTask, "AlarmService_Service");
thr.start();
/**
* The function that runs in our worker thread
*/
Runnable mTask = new Runnable()
{
public void run()
{
// Normally we would do some work here... for our sample, we will
// just sleep for 30 seconds.
long endTime = System.currentTimeMillis() + 15 * 1000;
while (System.currentTimeMillis() < endTime)
{
synchronized (mBinder)
{
try
{
mBinder.wait(endTime - System.currentTimeMillis());
}
catch (Exception e)
{
}
}
}
// Done with our work... stop the service!
AlarmService_Service.this.stopSelf();
}
};
/**
* This is the object that receives interactions from clients. See
* RemoteService for a more complete example.
*/
private final IBinder mBinder = new Binder()
{
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException
{
return super.onTransact(code, data, reply, flags);
}
};
- 实现服务运行小段时间后自己关闭
- apapche在windows2008服务器运行一段时间后服务关闭
- cmd 后关闭自己
- 实现 VMware 服务/网卡随程序运行和关闭
- shell脚本监控tomcat服务运行状态,服务关闭后进行重启
- 查看 服务运行时间
- VC 程序运行后自己删除自己
- android 启动后运行服务
- 花3分钟时间来关闭你电脑上没用的服务(加快你的电脑运行)
- perforce关闭服务后无法重启
- perforce关闭服务后无法重启
- matlab7.0运行后自动关闭解决方案
- VMware虚拟机关闭后托盘运行设置
- bat 运行后不自动关闭
- 运行bat文件后不关闭窗口
- ssh关闭后仍然运行当前进程
- windows bat文件 运行后不关闭
- 关闭网页后运行的方法
- 关于jdbc中Statement对象isClosed()的问题
- Quartz入门使用
- 电位器/电阻器型号命名方法
- 新浪博客的不足之处
- HDU 4727 The Number Off of FFF
- 实现服务运行小段时间后自己关闭
- 黑马程序员_Java语法基础(一)
- java 字节流与字符流的区别
- jstl标签,格式化日期和 数字<fmt>
- awakeFromNib和 viewDidLoad的区别
- 关于Android的EditText焦点问题
- iOS中数字的格式化
- C#网络编程(基本概念和操作) - Part.1
- ubuntu 12.04.2 基于 L3.0.35_1.1.0_121218_source LTIB 问题汇总