简体   繁体   中英

send data with service every 30seconds in android studio

Sorry for my english..:(

I already make a script service android for send data with api every 30 seconds. But I have a problems when I installed to my devices (My devices is xiaomi redmi note2). My service suddenly close about 3-4 minutes.. but I found the problem.I have to setting Manage apps battery usage-->turn Off restrict background activities .

for expert please give me suggest or solution about my problem. I want to send data with service without turn off restrict background activities .Thank you all.

There are two the main reason to restrict your background services mainly one is battery uses and another one is android os DOZE mode which device have os version greater than equal to 6.0 they all have DOZE mode which introduces by android os for battery optimization,

For the solution, you need to use foreground services which not restrict your uses. you can read more about foreground service from the android official document, https://developer.android.com/guide/components/services.html

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