handler.postDelayed is not working in onHandleIntent method of IntentService

前端 未结 5 1943
猫巷女王i
猫巷女王i 2021-01-17 22:50
final Handler handler = new Handler();
LOG.d(\"delay\");
handler.postDelayed(new Runnable() {
    @Override public void run() {
        LOG.d(\"notify!\");
        /         


        
5条回答
  •  梦毁少年i
    2021-01-17 23:35

    Handlers and Services will be predictable when the device screen is on. If the devices goes to sleep for example the Handler will not be a viable solution.

    A much more better and reliable solution will be to use: AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

提交回复
热议问题