我正在更新我的UI
而publishProgress()
更明确,我正在使用从云中获取的歌曲更新我的RecyclerView
,而我的列表已更新我想玩一两首歌,但我的广播不会发送到service
,直到AsyncTask
未完成,但highlight
中的某些功能RecyclerView
以及更新用户界面的功能。< / p>
在broadcast
正在运行时,有没有办法发送async task
?
答案 0 :(得分:0)
听起来你想播放从云端返回的歌曲,也许是第一个从云中检索出来的歌曲。尝试使用处理程序将要播放的歌曲发送回UI线程。
将这样的代码添加到您的活动中:
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
// Play song based on message
}
};
然后在你的publishProgress方法中发送一条消息,如下所示:
Message msg = handler.obtainMessage();
Bundle b = new Bundle();
b.putString("message", "value you need");
msg(b);
sendMessage(msg)
答案 1 :(得分:0)
我通过强制asynctask
与方法executeOnExecutor()