質問編集履歴
1
ログを記載しました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
HttpURLConnectionでHTTPステータスコードを確認したい
|
test
CHANGED
@@ -1,84 +1,24 @@
|
|
1
|
-
|
1
|
+
nakasho_dev 様のアドバイスをもとに修正2020/05/03
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
素人質問失礼いたします。
|
6
5
|
|
7
|
-
androidアプリのHTTP通信を勉強しています。指定したURLからHTML情報を文字列でとってきたいのですが、下記サンプルコード実行で
|
8
6
|
|
9
|
-
「Error reading from input stream」
|
10
|
-
|
11
|
-
との表記が出ます。
|
12
|
-
|
13
|
-
|
7
|
+
素人質問失礼いたします。サンプルにて学習中の初学者です。
|
14
8
|
|
15
9
|
|
16
10
|
|
17
|
-
|
11
|
+
対象URLがhttpsのサイトのHTMLを取得してTextViewに表示させたいです。
|
18
12
|
|
19
13
|
|
20
14
|
|
21
|
-
```ここに言語名を入力
|
22
|
-
|
23
|
-
packa
|
15
|
+
IOExceptionの例外が発生していて、ステータスコードを確認したいのですが出力方法がわかません。調べた限りではStacktraceは出力されず、IOExceptionの時は401とのことです出力方法がありましたら伺いたいです。
|
24
16
|
|
25
17
|
|
26
18
|
|
27
|
-
import android.content.Context;
|
28
|
-
|
29
|
-
import android.os.AsyncTask;
|
30
|
-
|
31
|
-
import android.os.SystemClock;
|
32
|
-
|
33
|
-
import android.service.autofill.TextValueSanitizer;
|
34
|
-
|
35
|
-
|
19
|
+
```Java
|
36
|
-
|
37
|
-
import android.widget.ProgressBar;
|
38
|
-
|
39
|
-
import android.widget.TextView;
|
40
20
|
|
41
21
|
|
42
|
-
|
43
|
-
import java.io.BufferedReader;
|
44
|
-
|
45
|
-
import java.io.IOException;
|
46
|
-
|
47
|
-
import java.io.InputStreamReader;
|
48
|
-
|
49
|
-
import java.lang.ref.WeakReference;
|
50
|
-
|
51
|
-
import java.net.HttpURLConnection;
|
52
|
-
|
53
|
-
import java.net.URL;
|
54
|
-
|
55
|
-
import java.nio.charset.StandardCharsets;
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
public class AsyncNet extends AsyncTask<String,Integer,String> {
|
60
|
-
|
61
|
-
private WeakReference<TextView> txtResult;
|
62
|
-
|
63
|
-
private WeakReference<ProgressBar> progress;
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
AsyncNet(Context context) {
|
68
|
-
|
69
|
-
super();
|
70
|
-
|
71
|
-
MainActivity activity = (MainActivity)context;
|
72
|
-
|
73
|
-
txtResult = new WeakReference<>((TextView)activity.findViewById(R.id.txtResult));
|
74
|
-
|
75
|
-
progress = new WeakReference<>((ProgressBar)activity.findViewById(R.id.progress));
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@Override
|
82
22
|
|
83
23
|
protected String doInBackground(String... params) {
|
84
24
|
|
@@ -122,52 +62,60 @@
|
|
122
62
|
|
123
63
|
}
|
124
64
|
|
125
|
-
|
126
|
-
|
127
|
-
|
65
|
+
```
|
128
|
-
|
129
|
-
protected void onPreExecute() {
|
130
|
-
|
131
|
-
progress.get().setVisibility(ProgressBar.VISIBLE);
|
132
|
-
|
133
|
-
}
|
134
66
|
|
135
67
|
|
136
68
|
|
137
|
-
|
69
|
+
```
|
138
70
|
|
139
|
-
|
71
|
+
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
|
140
72
|
|
141
|
-
|
73
|
+
2020-05-02 09:46:04.557 2546-2546/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: onReady
|
142
74
|
|
143
|
-
|
75
|
+
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
|
144
76
|
|
145
|
-
|
77
|
+
2020-05-02 09:46:04.563 2546-18479/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Detection finished
|
146
78
|
|
79
|
+
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
|
147
80
|
|
81
|
+
2020-05-02 09:46:04.569 2546-5516/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Stopping hotword detection.
|
148
82
|
|
149
|
-
|
83
|
+
2020-05-02 09:46:04.569 2546-18479/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4)
|
150
84
|
|
151
|
-
|
85
|
+
com.google.android.apps.gsa.shared.speech.b.g: Error reading from input stream
|
152
86
|
|
153
|
-
t
|
87
|
+
at com.google.android.apps.gsa.staticplugins.recognizer.j.a.a(SourceFile:28)
|
154
88
|
|
155
|
-
|
89
|
+
at com.google.android.apps.gsa.staticplugins.recognizer.j.b.run(SourceFile:15)
|
156
90
|
|
157
|
-
|
91
|
+
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
|
158
92
|
|
93
|
+
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
|
159
94
|
|
95
|
+
at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:14)
|
160
96
|
|
161
|
-
|
97
|
+
at com.google.android.apps.gsa.shared.util.concurrent.a.bl.run(SourceFile:4)
|
162
98
|
|
163
|
-
|
99
|
+
at com.google.android.apps.gsa.shared.util.concurrent.a.bl.run(SourceFile:4)
|
164
100
|
|
165
|
-
t
|
101
|
+
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
|
166
102
|
|
167
|
-
|
103
|
+
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
|
168
104
|
|
169
|
-
|
105
|
+
at java.lang.Thread.run(Thread.java:764)
|
170
106
|
|
107
|
+
at com.google.android.apps.gsa.shared.util.concurrent.a.ai.run(SourceFile:6)
|
108
|
+
|
109
|
+
Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
|
110
|
+
|
111
|
+
at com.google.android.apps.gsa.speech.audio.Tee.f(SourceFile:103)
|
112
|
+
|
113
|
+
at com.google.android.apps.gsa.speech.audio.au.read(SourceFile:2)
|
114
|
+
|
171
|
-
|
115
|
+
at java.io.InputStream.read(InputStream.java:101)
|
116
|
+
|
117
|
+
at com.google.android.apps.gsa.speech.audio.ao.run(SourceFile:18)
|
118
|
+
|
119
|
+
at com.google.android.apps.gsa.speech.audio.an.run(SourceFile:2)
|
172
120
|
|
173
121
|
```
|