No internet connection during doze mode

740 views Asked by At

In my application I need to download data from a website every 15 minutes. My problem is that when the phone is in doze mode the connection is absent due to energy savings.I tried with a WakefulBroadcastReceiver that is activated every 15 minutes by an Alam manager but the connection is almost always absent because the phone remains in doze mode. I have read of jobscheduler but not if it is useful to my problem and possibly how to implement it.Does anyone have an example of code that allows me to download data from a site by waking the phone from the doze mode every 15 minutes?

1

There are 1 answers

4
user10067214 On

Elletlar, I followed the example you indicated for the implementation of a jobScheduler in my project with excellent results. Now I wanted to ask you if in the "onJobStart" method you can indicate more 'intent as I did in the attached code. Thanks.

public boolean onStartJob(JobParameters params) {
    //first Job
    Intent service1 = new Intent(getApplicationContext(), Service1.class);
    getApplicationContext().startService(service1);
    Util.scheduleJob(getApplicationContext()); // first job!
    //second job
    Intent service2=new Intent(getApplicationContext(),Service2.class);
    getApplicationContext().startService(service2);
    Util.scheduleJob(getApplicationContext()); // second job!
    return true;
}