質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,3 +3,67 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
ファイルは.PHPを使用しています。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```AytaskClass.java
|
10
|
+
|
11
|
+
public class AsyncTaskClass extends AsyncTask<String, String, String> {
|
12
|
+
|
13
|
+
String strData;
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
@Override
|
18
|
+
|
19
|
+
protected String doInBackground (String... params) {
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Request request = new Request.Builder()
|
24
|
+
|
25
|
+
.url("接続したいURL")
|
26
|
+
|
27
|
+
.get()
|
28
|
+
|
29
|
+
.build();
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
OkHttpClient client = new OkHttpClient();
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
try {
|
38
|
+
|
39
|
+
Response response = client.newCall(request).execute();
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
strData = response.body().string();
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
} catch (IOException e) {
|
48
|
+
|
49
|
+
e.printStackTrace();
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
return strData;
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
@Override
|
60
|
+
|
61
|
+
protected void onPostExecute(String str) {
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
```
|