handler.postDelayed is not working in onHandleIntent method of IntentService

前端 未结 5 1992
猫巷女王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条回答
  •  日久生厌
    2021-01-17 23:23

    IntentService is not designed for such scenario. You can use a regular Service instead. You can put the handler inside the onStartCommand(). Don't forget to call stopSelf() on the Service instance to shut it down after the handler.postDelayed(){}

提交回复
热议问题