我认为我的问题可能与this stack post(Android远程方法数据限制)有关-仅返回的数据大小为661KB,并且文章说binder可以支持1MB。
情况如下:我有一个异步任务,它接受一个参数并调用一个 Web 服务,该服务返回一个由管道分隔的字符串和整数值组成的数组列表。然后我将这些值插入到 JAVA 数组列表中。在较小的数据集中,这很好用。在较大的数据集(即,这个 661KB 的数据集)中,我收到以下错误。
日志猫:
12-12 15:33:46.118: D/ProgressBar(14998): setProgress = 0
12-12 15:33:46.118: D/ProgressBar(14998): setProgress = 0, fromUser = false
12-12 15:33:46.118: D/ProgressBar(14998): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 10000
12-12 15:33:46.168: I/Async_GetAllTechSched(14998): create soap object
12-12 15:33:46.168: I/Async_GetAllTechSched(14998): create envelope
12-12 15:33:46.168: I/Async_GetAllTechSched(14998): create transport
12-12 15:33:46.208: D/ProgressBar(14998): updateDrawableBounds: left = 0
12-12 15:33:46.208: D/ProgressBar(14998): updateDrawableBounds: top = 0
12-12 15:33:46.208: D/ProgressBar(14998): updateDrawableBounds: right = 144
12-12 15:33:46.208: D/ProgressBar(14998): updateDrawableBounds: bottom = 144
12-12 15:33:51.613: D/dalvikvm(14998): GC_FOR_ALLOC freed 6262K, 37% free 18436K/29244K, paused 24ms, total 24ms
12-12 15:33:51.944: D/dalvikvm(14998): GC_FOR_ALLOC freed 594K, 36% free 18880K/29244K, paused 29ms, total 30ms
12-12 15:33:51.974: D/dalvikvm(14998): GC_FOR_ALLOC freed <1K, 34% free 19556K/29244K, paused 29ms, total 29ms
12-12 15:33:52.084: D/dalvikvm(14998): GC_FOR_ALLOC freed 2307K, 27% free 21387K/29244K, paused 20ms, total 20ms
12-12 15:33:52.204: D/dalvikvm(14998): GC_FOR_ALLOC freed 1597K, 25% free 22117K/29244K, paused 22ms, total 22ms
12-12 15:33:52.244: I/Async_GetAllTechSched(14998): pre SOAP response
12-12 15:33:52.244: I/Async_GetAllTechSched(14998): post SOAP response
12-12 15:33:52.244: I/Async_GetAllTechSched(14998): PRE - add response to array
12-12 15:33:52.244: I/Async_GetAllTechSched(14998): POST - add response to array
12-12 15:33:52.244: I/Async_GetAllTechSched(14998): pre-intent setting
12-12 15:33:52.244: I/Async_GetAllTechSched(14998): post-intent setting
12-12 15:33:52.254: I/Async_GetAllTechSched(14998): dismiss progress
12-12 15:33:52.264: E/JavaBinder(14998): !!! FAILED BINDER TRANSACTION !!!
12-12 15:33:52.274: E/ViewRootImpl(14998): sendUserActionEvent() mView == null
这是正在执行的代码:
Log.i("Async_GetAllTechSched", "create soap object");
SoapObject request = new SoapObject(svc_NAMESPACE, svc_METHOD_NAME);
Log.i("Async_GetAllTechSched", "create envelope");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
Log.i("Async_GetAllTechSched", "create transport");
HttpTransportSE androidHttpTransport = new HttpTransportSE(svc_URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(svc_SOAP_ACTION, envelope);
Log.i("Async_GetAllTechSched", "pre SOAP response");
// use SoapObject instead of SoapPrimitave
SoapObject response = (SoapObject) envelope.getResponse();
Log.i("Async_GetAllTechSched", "post SOAP response");
// get the count of the objects returned
int cnt = response.getPropertyCount();
Log.i("Async_GetAllTechSched", "PRE - add response to array");
// loop through returned object and pull out the strings
for (int i = 0; i < cnt; i++) {
// there should always be at least one return value
sResponse.add(response.getProperty(i).toString());
}
Log.i("Async_GetAllTechSched", "POST - add response to array");
} catch (Exception e) {
e.printStackTrace();
Log.e("!!ERROR!!", e.getMessage());
}
// Log.i("return in async", "*********");
return sResponse;
}
@Override
protected void onPostExecute(ArrayList<String> result) {
ArrayList<String> arrAllTechSchedule = new ArrayList<String>();
// get the count prior to the for loop
int iCnt = result.size();
//add the result of the web service call to the main scheduling page
for (int i = 0; i < iCnt; i++) {
//Log.i("i = ", Integer.toString(i));
//add the data to a ArrayList so we can add that to the adapter
arrAllTechSchedule.add(result.get(i).toString());
}
// lets launch the main schedule windows
Log.i("Async_GetAllTechSched", "pre-intent setting");
Intent intent = new Intent(_Context, ScheduleSelectTech.class);
intent.putStringArrayListExtra("arrAllTechSchedule", arrAllTechSchedule);
intent.putExtra("mode", "READ-ONLY");
Log.i("Async_GetAllTechSched", "post-intent setting");
// terminate the progress bar
progress.dismiss();
Log.i("Async_GetAllTechSched", "dismiss progress");
//launch the new form
_Context.startActivity(intent);
}
一旦意图开始,它就不会到达新的活动。我在 onCreate 中有一个 LOG.i,它永远不会被击中。过程调用没有超时。当我尝试返回较少数据的相同代码时,我没有收到错误消息。即,当我在将数据返回到异步任务的语句上放置一个 SELECT TOP 100 时,它完全没问题。
我想我的问题是——如果返回的数据小于 1MB,为什么会出错?如果是因为 1MB 的限制,我还能做些什么来绕过这个限制或以某种方式压缩返回的数据?
预期的设计是这个初始调用带回名称和与这些名称相关的约会(管道分隔)。我显示了一个仅包含微调器中名称的不同列表(取自数组列表)。当用户单击微调器中的名称时,它将启动一个新活动,该活动将显示与该名称关联的所有约会(同样,所有数据都来自初始数组列表)。所有数据都在第一个异步任务中收集并进行操作。这样做是为了减少网络调用的数量。这个任务在 2 个 Web 服务调用中是可行的,所以如果这是一个很好的答案 - 我只是希望有一种不同/更好的方法来做到这一点,这样我就可以限制 Web 服务调用并减少用户等待时间。