gpt4 book ai didi

android - 启动 Activity 时失败的 BINDER TRANACTION

转载 作者:行者123 更新时间:2023-11-29 21:22:37 25 4
gpt4 key购买 nike

我认为我的问题可能与此堆栈帖子 (Android remote method data limit) 有关 - 只有返回的数据大小为 661KB,文章说 Binder 可以支持 1MB。

情况是这样的:我有一个异步任务,它接受一个参数并调用一个 Web 服务,该服务返回一个由竖线分隔的字符串和整数值组成的数组列表。然后我获取这些值并将它们插入到 JAVA arraylist 中。在较小的数据集中,这工作正常。在较大的数据集(即这个 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);
}

一旦 Intent 开始,它就不会到达新的 Activity 。我在 onCreate 中有一个 LOG.i 并且从未被击中。过程调用没有超时。当我尝试返回较少数据的相同代码时,我没有收到错误。即,当我将 SELECT TOP 100 放在将数据返回到异步任务的语句上时,它完全没问题。

我想我的问题是 - 如果返回的数据小于 1MB,为什么会出错?如果是因为 1MB 的限制,我还能做些什么来绕过这个限制或以某种方式压缩返回的数据?

预期的设计是这个初始调用带回姓名和与这些姓名相关联的约会(竖线分隔)。我在微调器中显示了一个不同的名称列表(取自数组列表)。当用户在微调器中单击一个名称时,它将启动一个新 Activity ,该 Activity 将显示与该名称关联的所有约会(同样,所有数据都来自初始数组列表)。所有数据都在第一个异步任务中收集并进行处理。这样做是为了减少网络调用的数量。这个任务在 2 个 Web 服务调用中是可行的,所以如果这是答案,那很好 - 我只是希望有一种不同/更好的方法来做到这一点,这样我就可以限制 Web 服务调用并减少用户等待时间。

最佳答案

is there something else that I can do to either bypass this limitation

当然。不要使用 Intent extra 来传递数据。要么:

  • 将其重组为一个具有多个 fragment 的 Activity ,这样数据就永远不会离开 Activity ,或者

  • 让需要数据的 Activity 完成下载,或者

  • 非常非常小心使用静态数据成员从一个 Activity 获取数据到下一个 Activity ,竭力避免内存泄漏

关于android - 启动 Activity 时失败的 BINDER TRANACTION,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20554132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com