Reputation: 414
I'm developing app which is connecting with external device via socket. Constantly connection in background/foreground has the highest priority. User is notified even app is in background by showing notifications with received data. For this purpose Foreground Service has been used which is also bounded to activity. I saw that in upcoming Android 12 WorkingManager is recommended. Connection in background must work infinity (except killing app of course) and data from socket must come as quick as possible - just like stream. Can I achieve that with WorkManager or should I stay with Foreground Service ? I am still not 100% sure, please clarify someone ;) Thanks in advance !
Upvotes: 6
Views: 2301
Reputation: 74066
WorkManager is not made for your scenario. WorkManager is made for doing tasks like uploading files or downloading information while the app is in the background and then once done it stops.
Since you need a persistent connection always you should stick to what you are currently doing with a foreground service
Upvotes: 5