2013-12-12 27 views
1

所有,失敗粘結劑TRANACTION發起一項活動

我認爲我的問題,我與此有關的疊後(Android remote method data limit)時 - 只有數據的大小被返回是661KB和文章說,粘合劑可支持1MB。

這是情況:我有一個異步任務,它接受一個參數並調用一個Web服務,該服務返回管道分隔字符串和整數值的數組列表。我然後採取這些價值觀,並將他們插入JAVA arraylist。在較小的數據集中,這工作正常。在較大的數據集(即661KB數據集)中,我得到下面的錯誤。

的logcat:

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的限制,是否還有其他方法可以繞過此限制或以某種方式壓縮正在返回的數據?

預期的設計是該初始調用帶回與這些名稱(管道分隔)相關聯的名稱和約會。我在一個微調器中顯示一個不同名稱的名單(從arraylist中取得)。當用戶點擊微調器中的一個名字時,它將開始一個新的活動,顯示與該名稱相關的所有約會(同樣,所有數據來自初始數組列表)。所有的數據都在第一個異步任務中收集,並且只是被操縱。這樣做是爲了減少網絡電話的數量。這個任務在2個Web服務調用中是可行的,所以如果這是答案,那就沒問題了 - 我只是希望有一個不同的/更好的方法來做到這一點,這樣我就可以保持Web服務調用的有限性並減少用戶的等待時間。

感謝,

+0

「如果返回的數據小於1MB,爲什麼這個錯誤?」 - 當你轉換成Parcel時,你怎麼確定你的結果數據結構的內存大小小於1MB? – CommonsWare

+0

我知道我應該在發佈問題之前做到這一點......讓我得到可執行的parcelable類並確定要發送的數據包的大小。完成後我會進行更新。 – pwquigle

+0

我以爲這會更容易 - 我以前從未使用過包裹,所以讓我做一些閱讀,我會盡快回復您。對不起 - 我很新的Android開發... – pwquigle

回答

1

有沒有別的東西,我可以做要麼繞過這個限制

肯定。不要使用Intent附加項目來傳遞數據。或者:

  • 改組這與多個片段一個活動,所以數據不會離開活動,或

  • 有下載由需要該數據的活動來完成,或者

  • 非常非常小心使用靜態數據成員從一個活動的數據下得去,煞費苦心避免內存泄漏