0
這裏後使用吹氣是我的堆棧跟蹤:的Android IllegalStateException異常:嘗試調用結束
<StackTrace>java.lang.IllegalStateException: attempt to use Inflater after calling end
at java.util.zip.Inflater.checkOpen(Inflater.java:332)
at java.util.zip.Inflater.setInput(Inflater.java:312)
at com.android.okhttp.okio.InflaterSource.refill(InflaterSource.java:106)
at com.android.okhttp.okio.InflaterSource.read(InflaterSource.java:62)
at com.android.okhttp.okio.GzipSource.read(GzipSource.java:80)
at com.android.okhttp.okio.RealBufferedSource$1.read(RealBufferedSource.java:374)
at java.io.InputStream.read(InputStream.java:162)
at com.myProgram.services.DownloadService.onHandleIntent(DownloadService.java:58)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.os.HandlerThread.run(HandlerThread.java:61)
</StackTrace>
,這裏是從下載服務代碼:
InputStream input = connection.getInputStream();
byte data[] = new byte[1024];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
total += count;
Bundle resultData = new Bundle();
resultData.putInt("progress" ,(int) (total * 100/fileLength));
receiver.send(U_PROGRESS, resultData);
output.write(data, 0, count);
}
58行是:
while ((count = input.read(data)) != -1) {
隨機情況下會發生此錯誤。下載服務用於下載應用程序的新版本。