Android service error handling
What is best way for services error handling? For example, I have service which get some information from Internt, I want show to user some dialog with message when connectivity is bad. Or if I have some Util class for parse HTML that used by my service and exception oc开发者_高级运维cures in this Util class. How to show dialog? As I know DialogBuilder needs some Activity context, but Service context is wrong for this. Right? Thanks.
Have you considered using a notification? You can set a brief message and icon on the task bar, and the user has the option of clicking it, where you can open up a dialog with more details or they can just clear it. You can also clear it within the service if connectivity gets better.
精彩评论