作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想上传大文件(~10 - 100Mb wifi 或移动网络),但在后台,因为用户可能会离开应用程序,稍后系统将关闭应用程序(如果没有足够的内存)我创建了一个这种情况下的服务,但我的问题是,当我终止应用程序时,服务重新启动并重新开始上传。我发现同样的问题没有解决方案:
keeping background service alive after user exit app
My service is restarted each time the application is closed
所以不行,那有什么办法呢? youtube 应用程序如何???
最佳答案
如果您担心服务被终止的可能性,您应该通过 startForeground()
方法使用前台服务。
- A started service can use the startForeground(int, Notification) API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory. (It is still theoretically possible for the service to be killed under extreme memory pressure from the current foreground application, but in practice this should not be a concern.)
关于android - 在后台上传大文件(应用程序关闭时重新启动服务),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20891698/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!