简体   繁体   English

即使已卸载应用程序,WorkManager实例仍保持活动状态(?)

[英]WorkManager instances keep alive even after the app is uninstalled (?)

I've been trying out the new Android WorkManager API and it seems to work fine. 我一直在尝试新的Android WorkManager API ,它似乎运行良好。 However I noticed something while testing my app: before creating a new periodic worker instance, I check for status to avoid creating more than one: 但是在测试我的应用程序时,我注意到了一些东西:在创建新的定期工作程序实例之前,我检查状态以避免创建多个实例:

WorkManager.getInstance().getStatusesByTag(myTag)
            .observe(lifecycleOwner, Observer { status ->
                // creates a new worker if status returns nothing
            })

The first time app launched the status returned nothing and a new one was created, but then I needed to uninstall my app and when it launched again there was already a worker created, from the logs: 应用程序首次启动时,状态什么都没有返回,并且创建了一个新的状态,但是随后我需要卸载我的应用程序,当它再次启动时,已经从日志中创建了一个工作进程:

WorkStatus{mId='UUID', mState=ENQUEUED, mOutputData=androidx.work.Data@0, mTags=[tag, tagName]}]

I know the API is still in alpha, but I was wondering if this is expected and if this won't be a problem. 我知道API仍处于Alpha状态,但我想知道这是否是预期的,并且这不会成为问题。 I think that if user uninstalls your app these background tasks should be removed too. 我认为,如果用户卸载您的应用程序,那么这些后台任务也应删除。 I've been trying to find some information related to this, but I couldn't so far. 我一直在努力寻找与此相关的信息,但到目前为止还没有找到。 Has anyone seen this or can anyone point me a documentation or something similar? 有没有人看过这个文件,或者有人可以向我指出文件或类似内容?

Thank you for your help 谢谢您的帮助

Of course NOT . 当然不是 Once you uninstall the app there will be no instance of WorkManager. 卸载应用程序后,将没有WorkManager的实例。

WorkManager API will work even if your app is process has been killed but not after uninstallation of app. 即使您的应用程序进程已被杀死,WorkManager API也将起作用,但在卸载应用程序后则不会。 WorkManager API implementation is part of your Application but not Android OS. WorkManager API实施是您的应用程序的一部分,但不是Android OS的一部分。

Please check your uninstallation again. 请再次检查您的卸载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使应用程序被杀死,alarmmanager 也要保持活动状态 - Keep alarmmanager alive even if the app is killed 即使在 onComplete() 之后也保持流活跃 - Keep stream alive even after onComplete() 即使在卸载应用程序后,如何记住登录firebase手机Auth? - How to remember login in firebase phone Auth even after app is uninstalled? 在 Android 上卸载/重新安装应用程序后保留 SQFlite 数据的最佳方法? - Best way to keep SQFlite data after app is uninstalled/reinstalled on Android? 如何在应用程序被杀死时让 WorkManager 活着? - How to make WorkManager alive when app is killed? 即使在设备重启后也保持 Android 调试器处于活动状态 - Keep Android debugger alive even after device restart 即使活动遭到破坏,如何保持服务的生命力? - How to keep service alive even after activity destroyed? 即使在任务管理器杀死进程后,也要保持android警报活动 - Keep android alarms alive, even after process killed by a task manager 即使重新启动电话后,如何仍保持广播收录机仍然有效? - How to keep broadcast recevier alive even after restarting the phone? 即使关闭应用程序,如何保持服务正常运行? - How to keep service alive even when I close the app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM