Android: Passing variables to an already running service

前端 未结 2 1948
情话喂你
情话喂你 2021-02-19 04:29

I am having issues passing a value from an Activity to an already running service. I was wondering what the best approach to take would be? Adding extras wont work as I believe

2条回答
  •  日久生厌
    2021-02-19 04:43

    If your service is not an IntentService, you can call startService(...) as many times you want. The service will run the first time but next calls will result in new onStartCommand() calls with the new extras you need.

    Check this answer and the doc.

提交回复
热议问题