ios后台申请运行一定的时间
来源:互联网 发布:centos shell脚本编程 编辑:程序博客网 时间:2024/05/01 02:09
在 应用的appdelegate里面的- (void)applicationDidEnterBackground:(UIApplication *)application代理方法中加上:
UIApplication *app = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier taskId;taskId = [app beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"后台任务超时被退出");
[app endBackgroundTask:taskId];
}];
if(taskId == UIBackgroundTaskInvalid)
{
return;
}
//队列中等待(类似于等待线程,个人理解)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
NSLog(@"后台任务据最长时限还有 %f 秒",app.backgroundTimeRemaining);
[NSThread sleepForTimeInterval:32]; //等待32秒
NSLog(@"后台任务据最长时限还有 %f 秒",app.backgroundTimeRemaining);
[app endBackgroundTask:taskId];//通知系统后台任务已处理完毕
});
}
- ios后台申请运行一定的时间
- iOS申请持续的后台时间
- 后台申请3分钟运行时间
- IOS 后台挂起,向IOS申请后台无限时间
- ios 后台长短时间运行
- (最新)iOS后台运行时间
- iOS后台运行延长时间
- iOS App进入后台获取更多的运行时间
- iOS App进入后台获取更多的运行时间
- iOS App进入后台获取更多的运行时间
- iOS App进入后台获取更多的运行时间
- iOS App进入后台获取更多的运行时间
- iOS App进入后台获取更多的运行时间
- iOS App进入后台获取10min的运行时间
- iOS App进入后台获取更多的运行时间
- IOS的后台运行
- IOS的后台运行
- IOS的后台运行
- NUMA (Non- Uniform Memory Access Architecture)
- Win8系统中如何显示/隐藏文件扩展名
- shell 逐行读取文件的内容
- 【Visual C++】游戏开发笔记DirectX开发环境的快速配置
- Android Camera调用流程
- ios后台申请运行一定的时间
- sql语句集
- android camera(二):摄像头工作原理、s5PV310 摄像头接口(CAMIF)
- oracle日期相关
- android睡眠唤醒调试
- 【网站安全】网站通常面临的几种安全威胁及应对方式
- Debian Stable(squeeze6.0.7) 升级到最新的stable(Wheezy7.0),tzdata broken,重新安装N显卡驱动
- linux tune2fs命令详解
- 华为软件编程规范学习(九)--质量保证