IntentService에서 파일을 다운로드하는 중 치명적인 예외가 발생합니다. 작은 파일은 잘 다운로드됩니다. 그러나 9MB + 파일은 문제이며 고속 WIFI 연결에서도 다운로드가 끝나지 않는 것처럼 보입니다. 몇 분 후 치명적인 예외가 있습니다. 문제는 사이클 (조건 라인) 동안입니다.IntentService에서 파일 다운로드 치명적인 예외가 발생했습니다
일부 힌트를주세요. 내가 뭔가를 놓친 거지 ..
예외 :
FATAL EXCEPTION: IntentService[DownloadService]
java.lang.OutOfMemoryError
at java.lang.String.<init>(String.java:432)
at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:642)
at java.lang.StringBuffer.toString(StringBuffer.java:723)
at com.splunk.mint.network.io.InputStreamMonitor.updateBody(InputStreamMonitor.java:123)
at com.splunk.mint.network.io.InputStreamMonitor.read(InputStreamMonitor.java:77)
at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
at java.io.BufferedInputStream.read(BufferedInputStream.java:309)
at java.io.InputStream.read(InputStream.java:163)
at cz.ppmfactum.android_smartaudit.application.application.connection.DownloadService.download(DownloadService.java:103)
at cz.ppmfactum.android_smartaudit.application.application.connection.DownloadService.onHandleIntent(DownloadService.java:46)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
코드 :
충돌 지금 다시 이동 ... 민트라는 새로운 BugSense 라이브러리에 의해 아마 발생private synchronized void download(Intent intent) throws Exception {
String urlString = intent.getStringExtra("url");
Log.e("URL DOWNLOAD", urlString);
String path = intent.getStringExtra("path");
String name = intent.getStringExtra("name") + ".temp";
FileOutputStream output;
URL url = new URL(urlString);
URLConnection connection = url.openConnection();
connection.connect();
InputStream input = new BufferedInputStream(url.openStream());
File rootFile = new File(path);
if (!rootFile.exists())
rootFile.mkdirs();
File outputFile = new File(rootFile, name);
if (outputFile.exists()) outputFile.delete();
output = new FileOutputStream(outputFile);
byte data[] = new byte[1024];
int count;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
FileControler.renameFile(outputFile, intent.getStringExtra("name"));
downloadedFile = new File(outputFile.getParent(), intent.getStringExtra("name"));
output.flush();
output.close();
input.close();
}
'com.splunk.mint.network.io.InputStreamMonitor'의 작성자에게 충돌하는 코드가 있으므로 문의하십시오. – CommonsWare
오 .. 고맙습니다. :) –