How can repeating AlarmManager start AsyncTask?

前端 未结 2 1713
感动是毒
感动是毒 2021-01-15 18:55

I usually write this code to start a service with AlarmManager.

    intent = new Intent(getActivity(), someservice.class);
    pendingNotificat         


        
2条回答
  •  北海茫月
    2021-01-15 19:19

    This is how you can do it:

    1.) Define a static intent (intent1) and use it to pass to AlarmManager when setting time. So now when ever time, will lapse; AlarmManager will notify by sending intent1.

    2.) On onReceive of BroadcastReceiver of intent1, start a AsyncTask. At end end of AsyncTask, set the next time for AlarmManager.

提交回复
热议问题