简体   繁体   中英

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. 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. 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 API will work even if your app is process has been killed but not after uninstallation of app. WorkManager API implementation is part of your Application but not Android OS.

Please check your uninstallation again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM