postDelayed() in a Service

前端 未结 3 363
我寻月下人不归
我寻月下人不归 2021-01-12 17:36

I\'m trying to restart service from itself in a few time. My code looks like this (inside the onStartCommand(...))

Looper.prepare();
Handler han         


        
3条回答
  •  执念已碎
    2021-01-12 18:09

    Replace

    Handler handler = new Handler();
    

    With

    Handler handler = new Handler(Looper.getMainLooper());
    

    Worked for me.

提交回复
热议问题