I have a remote service in android. It's binded to my list activity and sends some messages to it. The service contins scheduled task in it. I also have preference: refresh interval for my service. All I want is to restart the service when user changes refresh interval. Butif I do it in onSharedPreferenceChanged() then I loose the connection from my list activity. How can I solve it? Thanks.
I know th开发者_开发技巧at I can use Broadcast Reciever. Is there another way?
I have a remote service in android.
Why? Why not a local service?
The service contins scheduled task in it.
Why? Why not use AlarmManager
, so your service isn't just sitting around in RAM, watching time pass?
All I want is to restart the service when user changes refresh interval.
Why? Why not just change your AlarmManager
schedule? If you use a local service, your service can use a SharedPreferences
and setOnSharedPreferenceChangeListener()
to be automatically notified of changes in the refresh interval.
精彩评论