以下代码中的正确方法是什么(对我来说结构有点复杂)从方法 gotUrl() 获取 url 到 AsyncTask 的 doInBackground() 方法,以便在 doInBackground() 之后在 onPostExecute() 中使用它方法已经完成了它的任务?
public class PlayerActivity extends CustomActivity implements
ProblemListener{
public class PlayChannel extends
AsyncTask<CustomChangeChannel, String, String> {
@Override
protected String doInBackground(CustomChangeChannel... params) {
initOctoshapeSystem();
return url;
}
@Override
protected void onPostExecute(String url){
}
}
public void initOctoshapeSystem() {
os = OctoStatic.create(this, this, null);
os.setOctoshapeSystemListener(new OctoshapeSystemListener() {
@Override
public void onConnect() {
mStreamPlayer = setupStream(OCTOLINK);
mStreamPlayer.requestPlay();
}
});
}
public StreamPlayer setupStream(final String stream) {
StreamPlayer sp = os.createStreamPlayer(stream);
sp.setStatusChangedListener(new StatusChangedListener() {
@Override
public void statusChanged(byte oldStatus,
final byte newStatus) {
runOnUiThread(new Runnable() {
@Override
public void run() {
//todo
}
});
}
});
sp.setListener(new StreamPlayerListener() {
@Override
public void gotUrl(String url) {
//String to be passed
}
});
return sp;
}
}