سؤال

i'm developing an android app with strict requirements;

the app should be able to connect to a web server every 30 or 15 mins and send an sms automatically

the server status (a simple string generated by server) should be displayed on a widget the app should be persistent << boot up automatically, and run continuously (each 30mins) till turning off the phone.

i can keep the phone on/active by using power management

is it ok to use widget refresh event for this and is it reliable and capable for this, or do i need a seperate madule for background tasks and use the widget for just display the info?

What is the best model for this?

هل كانت مفيدة؟

المحلول

You have to work with AlarmManager for reliable, long term scheduling. So it will work even on idle mode. No need to keep the aplication alive and powermangement locks to make the device active. it will drain your batt. and all other resources.

instead you can apply a wakelock when the scheduled task is started and then you can remove the lock as soon as the task is completed. AlarmManager will keep running in background and will call to your activities on given time interval.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top