네, 그 권리. U는 전화하고 싶을만큼 많이 할 수 있습니다. 하지만 약간의 수정을 수행 할 수 있습니다. 호출 4 AsyncTask를 instend, u는 하나의 AsyncTask를 일반 흐름으로 만들 수 있습니다.
`
public class GetDataFromNetwork extends AsyncTask<Void,String,Object> {private String ipAddress;
private String webService;
private String nameSpace;
private String methodName;
private Context context;
private ProgressDialog progressDialog;
private SoapObject request;
private GetDataCallBack callBack;
/**
* Set default progress Bar properties. Internal function called from setConfig
*
* @param progressBarStyle : Progress Dialog style (spinner or horizontal)
* @param message : Message to be displayed on progressBar
*/
protected void setProgresDialogProperties(int progressBarStyle,
String message) {
progressDialog = new ProgressDialog(context);
progressDialog.setProgress(0);
progressDialog.setMax(100);
progressDialog.setProgressStyle(progressBarStyle);
progressDialog.setMessage(message);
}
public GetDataFromNetwork(Context context,int progressBarStyle,String message ,GetDataCallBack callBack) {
this.callBack=callBack;
this.context=context;
setProgresDialogProperties(progressBarStyle, message);
}
/**
* Used for setting up the location and config of remote location/webservice
* @param ipAddress : IP of webservice
* @param webService : Name of webservice
* @param nameSpace : NameSpace of webService
* @param methodName :Name of function of the particular webservice
*/
public void setConfig(String ipAddress,String webService,String nameSpace,String methodName){
this.ipAddress=ipAddress;
this.webService=webService;
this.nameSpace=nameSpace;
this.methodName=methodName;
}
/**
* Set parameter in SoapObject
* @param requestParamater : Map of request
*/
@SuppressWarnings("rawtypes")
public void sendData(HashMap<String, Object> requestParamater) {
}
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog.show();
}
@Override
protected Object doInBackground(Void... params) {
return result;
}
@Override
protected void onPostExecute(Object result) {
super.onPostExecute(result);
progressDialog.dismiss();
}`
이제 ur 서버와 상호 작용하고 싶을 때이 클래스를 호출 할 수 있습니다.
각각에 과중한 작업을 수행해야합니까? 왜냐하면 당신이 모든 웹 서비스에서 데이터를 가져 오지 않는다면, 나는 그것을 줄일 것입니다. 첫 번째 AsyncTask에서 모든 것을 캐시하고 앱을 탐색 할 때 데이터를로드하려고 시도하십시오. – WarrenFaith
모두 4 개의 다른 webservice 호출을 사용합니다. –
다음 네 가지 작업을 수행하는 것이 좋습니다. 자신의 활동에서만 액세스하는 경우에는 내부 클래스이어야합니다. – WarrenFaith