Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android fail retrofit http call in deep sleep mode

I have a galaxy tabA tablet on Android 7.0 and I use Retrofit 2 to send http call to my server every 15 minutes to log information about the tablet. My tablet enter in "deep sleep" mode when it is not charging for more than 5 minutes with screen off.
During this deep sleep mode, none of my calls can reach my server and I receive a "connection timeout error".

Does someone has a better understanding of "deep sleep" mode and explain here what is the best way to achieve my behavior (send logs every 15 minutes h24/24) ?

Can someone explain if it is a retrofit bug or an Android feature or something else ?

like image 243
Vincent Chann Avatar asked Nov 30 '25 13:11

Vincent Chann


1 Answers

To solve this problem you must use evernote library : https://github.com/evernote/android-job

In fact, "doze mode" block access to network in deep sleep and wake up at periodic time to let network access open.
This library helped me catch those holy periodic window with network to send my server logs.

Just follow the tutorial in readme to configure this feature.

like image 115
Vincent Chann Avatar answered Dec 02 '25 04:12

Vincent Chann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!