AlarmManager and BroadcastReceiver instead of Service - is that bad ? (Timeout)

后端 未结 3 633
长发绾君心
长发绾君心 2020-12-05 08:01

BACKGROUND INFO:

I need to update some data from the web, about every hour or so, even when my app is closed. The update of the data itself takes ab

3条回答
  •  独厮守ぢ
    2020-12-05 08:54

    For information, I've tried with a new thread and it works when on Wifi (takes about 1'30" to update the data when phone is asleep, it doesn't get 'killed' !

    //let's try with a new separate thread ?
            new Thread(new Runnable() {
                public void run() {
                    Refresh_HIST_DATA();
                }
              }).start();
    

    but NOT when on Mobile (GPRS), as it gets killed after about 10 secs!

    It's half-a-solution for the moment and I will try CommonsWare's solution for a cleaner/more sustainable approach...

    Let's see if the new thread solution works allways fine or was just luck (I've tested only during a couple hours) ...

    If anyone else has another suggestion, please do post it.

提交回复
热议问题