nakasho_dev 様のアドバイスをもとに修正2020/05/03
素人質問失礼いたします。サンプルにて学習中の初学者です。
対象URLがhttpsのサイトのHTMLを取得してTextViewに表示させたいです。
IOExceptionの例外が発生していて、ステータスコードを確認したいのですが出力方法がわかません。調べた限りではStacktraceは出力されず、IOExceptionの時は401とのことです出力方法がありましたら伺いたいです。
Java
1 2 protected String doInBackground(String... params) { 3 publishProgress(30); 4 SystemClock.sleep(3000); 5 publishProgress(60); 6 StringBuilder builder = new StringBuilder(); 7 try { 8 URL url = new URL(params[0]); 9 HttpURLConnection con = (HttpURLConnection)url.openConnection(); 10 con.setRequestMethod("GET"); 11 BufferedReader reader = new BufferedReader(new InputStreamReader( 12 con.getInputStream(), StandardCharsets.UTF_8)); 13 String line; 14 while ((line = reader.readLine()) != null){ 15 builder.append(line); 16 } 17 } catch (IOException e) { 18 e.printStackTrace(); 19 } 20 publishProgress(100); 21 return builder.toString(); 22 }
2020-05-02 09:46:04.556 2546-18518/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_started com.google.android.apps.gsa.staticplugins.aa.c@516eb34 2020-05-02 09:46:04.557 2546-2546/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: onReady 2020-05-02 09:46:04.562 2546-18518/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_close com.google.android.apps.gsa.staticplugins.aa.c@516eb34 2020-05-02 09:46:04.563 2546-18479/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Detection finished 2020-05-02 09:46:04.565 2546-18479/com.google.android.googlequicksearchbox:search W/ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream 2020-05-02 09:46:04.569 2546-5516/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Stopping hotword detection. 2020-05-02 09:46:04.569 2546-18479/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4) com.google.android.apps.gsa.shared.speech.b.g: Error reading from input stream at com.google.android.apps.gsa.staticplugins.recognizer.j.a.a(SourceFile:28) at com.google.android.apps.gsa.staticplugins.recognizer.j.b.run(SourceFile:15) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:14) at com.google.android.apps.gsa.shared.util.concurrent.a.bl.run(SourceFile:4) at com.google.android.apps.gsa.shared.util.concurrent.a.bl.run(SourceFile:4) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) at com.google.android.apps.gsa.shared.util.concurrent.a.ai.run(SourceFile:6) Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space. at com.google.android.apps.gsa.speech.audio.Tee.f(SourceFile:103) at com.google.android.apps.gsa.speech.audio.au.read(SourceFile:2) at java.io.InputStream.read(InputStream.java:101) at com.google.android.apps.gsa.speech.audio.ao.run(SourceFile:18) at com.google.android.apps.gsa.speech.audio.an.run(SourceFile:2)