Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
即使应用程序在后台运行,我也希望完成上传操作。即使应用程序在打开其他应用程序时被杀死,该过程也应该完成。有人可以建议我一些解决方案吗?
使用服务,并为其附加持续 通知。这将阻止 Android 大体上杀死您的应用程序,但在最极端的情况下您仍然有可能被杀死。但是,这是您能做的最好的事情,除非您的应用在整个上传过程中处于前台。
您的应用程序不会因打开其他应用程序而被杀死。检查 Android 生命周期。上传文件的最佳方式是在线程上进行。无论您关闭应用程序还是未启动线程都将继续工作。