Problems in Calling AsyncTask from IntentService

后端 未结 5 1463
别跟我提以往
别跟我提以往 2021-01-05 22:24

I have created IntentService class and performing asyncTask but getting exception when onPreExecute() is called at this code line

5条回答
  •  难免孤独
    2021-01-05 22:43

    First, IntentService already uses a background thread. You do not need another background thread. Do the work that needs to be done in the background in onHandleIntent().

    Second, a Service cannot display a Dialog. Instead, let the UI layer of your app know that the work was done via a message on an event bus (e.g., LocalBroadcastManager, greenrobot's EventBus, Square's Otto). If the UI layer does not handle the event, your service can raise a Notification or otherwise let the user know about the work that was done, if that is needed.

提交回复
热议问题