我在onresume()中調用web服務以從服務器獲取數據..問題是如果用戶最小化並再次打開該應用程序,它將調用Web服務來獲取數據。我不想在這種情況下再次加載數據。在這種情況下加載數據的最佳方式是什麼?在onresume中從webservice加載數據
@Override
protected void onResume() {
lAttendence= getAttendence ('goku' ,'20/mar/2016' ,'21/mar/2016');
EtAtendence.setText(lAttendence)
super.onResume();
}
public String getAttendence(String pStuid, String pFromdate, String pTodate){
final String SOAP_ACTION = "http://adad.org/attendenceDetail";
final String METHOD_NAME = "attendenceDetail";
final String NAMESPACE = "http://xxxx.org/";
final String URL = "http://xxxxx.in/service.asmx";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("pStuID", pStuid);
request.addProperty("pFromDate",pFromdate);
request.addProperty("pTodate",pTodate);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
String result="";
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
Object responses = envelope.getResponse();
result=responses.toString();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
請更具體一些,並顯示一些代碼。 – barq
看看加載程序模式 –