teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

15

マークダウン記法を用いて読みやすくしました。

2020/12/13 10:38

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -202,6 +202,68 @@
202
202
  }
203
203
 
204
204
  ```
205
+ ###【ターミナル】
206
+ ```
207
+ iMac215-2011:ddd admin$ curl "http://api.openweathermap.org/data/2.5/forecast?id=1850147&units=metric&cnt=1&appid="MyAppID" | jq '.'
208
+ % Total % Received % Xferd Average Speed Time Time Time Current
209
+ Dload Upload Total Spent Left Speed
210
+ 100 590 100 590 0 0 2163 0 --:--:-- --:--:-- --:--:-- 2169
211
+ {
212
+ "cod": "200",
213
+ "message": 0,
214
+ "cnt": 1,
215
+ "list": [
216
+ {
217
+ "dt": 1607860800,
218
+ "main": {
219
+ "temp": 10.04,
220
+ "feels_like": 6.37,
221
+ "temp_min": 10.04,
222
+ "temp_max": 10.54,
223
+ "pressure": 1010,
224
+ "sea_level": 1010,
225
+ "grnd_level": 1006,
226
+ "humidity": 78,
227
+ "temp_kf": -0.5
228
+ },
229
+ "weather": [
230
+ {
231
+ "id": 802,
232
+ "main": "Clouds",
233
+ "description": "scattered clouds",
234
+ "icon": "03n"
235
+ }
236
+ ],
237
+ "clouds": {
238
+ "all": 43
239
+ },
240
+ "wind": {
241
+ "speed": 4.05,
242
+ "deg": 97
243
+ },
244
+ "visibility": 10000,
245
+ "pop": 0,
246
+ "sys": {
247
+ "pod": "n"
248
+ },
249
+ "dt_txt": "2020-12-13 12:00:00"
250
+ }
251
+ ],
252
+ "city": {
253
+ "id": 1850147,
254
+ "name": "Tokyo",
255
+ "coord": {
256
+ "lat": 35.6895,
257
+ "lon": 139.6917
258
+ },
259
+ "country": "JP",
260
+ "population": 0,
261
+ "timezone": 32400,
262
+ "sunrise": 1607809343,
263
+ "sunset": 1607844516
264
+ }
265
+ }
266
+ iMac215-2011:ddd admin$
205
267
 
206
- ![イメージ説明](7bd6aac8b87a66b44e1070cdd708e8b2.png)
268
+ ```
207
269
  ![イメージ説明](77f8aa2f869a633ac316d07fe5d76e22.png)

14

2020/12/13 10:38

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
 
45
45
  ###【AndroidManifest.xml】
46
- ``xml
46
+ ```xml
47
47
  ?xml version="1.0" encoding="utf-8"?>
48
48
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
49
49
  package="com.example.ddd">

13

2020/12/13 07:07

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
 
45
45
  ###【AndroidManifest.xml】
46
- ```xml
46
+ ``xml
47
47
  ?xml version="1.0" encoding="utf-8"?>
48
48
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
49
49
  package="com.example.ddd">

12

画像を挿入しました

2020/12/13 03:02

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- #androidStudioで天気予報のアプリを作りたいのですが、エラーが出まお力お貸しして頂けないでしょうか。
1
+ #androidStudioで天気予報のアプリを作りたいのですが、jsonで取得したデが出力出来せん
2
2
  ####[参照][天気予報のアプリ](https://tech-blog.rakus.co.jp/entry/android-studio/weather-hacks)
3
3
 
4
4
 

11

画像を挿入しました

2020/12/10 22:06

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -93,7 +93,7 @@
93
93
  public void changeTextView(View view) {
94
94
  // 非同期処理(AsyncHttpRequest#doInBackground())を呼び出す
95
95
  try {
96
- new AsyncHttpRequest(this).execute(new URL("http://api.openweathermap.org/data/2.5/forecast?id=1850147&units=metric&cnt=1&appid=MY {APEKEY}"));
96
+ new AsyncHttpRequest(this).execute(new URL("http://api.openweathermap.org/data/2.5/forecast?id=1850147&units=metric&cnt=1&appid={MY APEKEY}"));
97
97
  } catch (MalformedURLException e) {
98
98
  e.printStackTrace();
99
99
  }

10

画像を挿入しました

2020/12/10 21:54

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,9 +1,8 @@
1
1
  #androidStudioで天気予報のアプリを作りたいのですが、エラーが出ます。お力お貸しして頂けないでしょうか。
2
2
  ####[参照][天気予報のアプリ](https://tech-blog.rakus.co.jp/entry/android-studio/weather-hacks)
3
3
 
4
- #エラーメッセージ
4
+
5
- ###W/System.err: 正常に接続できていません。statusCode:302
5
+
6
- ![イメージ説明](35271dd2af1090fa82ba4204aeb6afdf.png)
7
6
  ###【activity_main.xml】
8
7
 
9
8
  ```xml
@@ -94,7 +93,7 @@
94
93
  public void changeTextView(View view) {
95
94
  // 非同期処理(AsyncHttpRequest#doInBackground())を呼び出す
96
95
  try {
97
- new AsyncHttpRequest(this).execute(new URL("http://weather.livedoor.com/forecast/webservice/json/v1?city=270000"));
96
+ new AsyncHttpRequest(this).execute(new URL("http://api.openweathermap.org/data/2.5/forecast?id=1850147&units=metric&cnt=1&appid=MY {APEKEY}"));
98
97
  } catch (MalformedURLException e) {
99
98
  e.printStackTrace();
100
99
  }
@@ -175,9 +174,9 @@
175
174
 
176
175
  // 受け取ったJSON文字列をパース
177
176
  JSONObject jsonObject = new JSONObject(response.toString());
178
- JSONObject todayForcasts = jsonObject.getJSONArray("forecasts").getJSONObject(TODAY_FORCAST_INDEX);
177
+ JSONObject todayForcasts = jsonObject.getJSONArray("weather").getJSONObject(TODAY_FORCAST_INDEX);
179
178
 
180
- return todayForcasts.getString("dateLabel") + "の天気は " + todayForcasts.getString("telop");
179
+ return "今日の天気は" + todayForcasts.getString("main");
181
180
  } catch (IOException e) {
182
181
  e.printStackTrace();
183
182
  return null;
@@ -204,5 +203,5 @@
204
203
 
205
204
  ```
206
205
 
207
-
206
+ ![イメージ説明](7bd6aac8b87a66b44e1070cdd708e8b2.png)
208
207
  ![イメージ説明](77f8aa2f869a633ac316d07fe5d76e22.png)

9

エラーメッセージを加えました。

2020/12/10 21:53

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,9 @@
1
- #androidStudioで天気予報のアプリを作りたいのですが、その日の天気情報が出ません。(エラーていせんお力お貸しして頂けないでしょうか。
1
+ #androidStudioで天気予報のアプリを作りたいのですが、エラー出ま。お力お貸しして頂けないでしょうか。
2
2
  ####[参照][天気予報のアプリ](https://tech-blog.rakus.co.jp/entry/android-studio/weather-hacks)
3
3
 
4
+ #エラーメッセージ
5
+ ###W/System.err: 正常に接続できていません。statusCode:302
6
+ ![イメージ説明](35271dd2af1090fa82ba4204aeb6afdf.png)
4
7
  ###【activity_main.xml】
5
8
 
6
9
  ```xml
@@ -201,5 +204,5 @@
201
204
 
202
205
  ```
203
206
 
204
- ![イメージ説明](0f73d55f9f5befc51ab1590f582143c0.png)
207
+
205
208
  ![イメージ説明](77f8aa2f869a633ac316d07fe5d76e22.png)

8

マークダウン記法を用いて読みやすくしました。

2020/11/29 21:50

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- #androidStudioで天気予報のアプリを作りたいのですが、その日の天気情報が出ません。(エラーは出ていません。)お力お貸しして頂けないでしょうか。
1
+ #androidStudioで天気予報のアプリを作りたいのですが、その日の天気情報が出ません。(エラーは出ていません。)お力お貸しして頂けないでしょうか。
2
2
  ####[参照][天気予報のアプリ](https://tech-blog.rakus.co.jp/entry/android-studio/weather-hacks)
3
3
 
4
4
  ###【activity_main.xml】

7

画像を挿入しました

2020/11/29 05:30

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -201,4 +201,5 @@
201
201
 
202
202
  ```
203
203
 
204
- ![イメージ説明](0f73d55f9f5befc51ab1590f582143c0.png)
204
+ ![イメージ説明](0f73d55f9f5befc51ab1590f582143c0.png)
205
+ ![イメージ説明](77f8aa2f869a633ac316d07fe5d76e22.png)

6

参照リンクも増やしました。

2020/11/29 05:28

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -199,4 +199,6 @@
199
199
  }
200
200
  }
201
201
 
202
- ```
202
+ ```
203
+
204
+ ![イメージ説明](0f73d55f9f5befc51ab1590f582143c0.png)

5

マークダウン記法を用いて読みやすくしました。

2020/11/29 05:24

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,16 +1,6 @@
1
- #androidStudioで天気予報のアプリを作りたいのですが、シンボル見つかりませんエラー出まどうかお力お貸しして頂けないでしょうか。
1
+ #androidStudioで天気予報のアプリを作りたいのですが、その日の天気情報ません。(エラーていせん)お力お貸しして頂けないでしょうか。
2
2
  ####[参照][天気予報のアプリ](https://tech-blog.rakus.co.jp/entry/android-studio/weather-hacks)
3
- ## エラーメッセージ
4
3
 
5
-
6
-
7
- ```
8
- new AsyncHttpRequest(result.this).execute(new URL("http://weather.livedoor.com/forecast/webservice/json/v1?city=270000"));
9
- ^
10
- シンボル: クラス AsyncHttpRequest
11
- 場所: クラス MainActivity
12
- ```
13
-
14
4
  ###【activity_main.xml】
15
5
 
16
6
  ```xml
@@ -52,9 +42,31 @@
52
42
 
53
43
  ###【AndroidManifest.xml】
54
44
  ```xml
45
+ ?xml version="1.0" encoding="utf-8"?>
46
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
47
+ package="com.example.ddd">
55
- <!-- ネット接続を許可する -->
48
+ <!-- ネット接続を許可する -->
56
- <uses-permission android:name="android.permission.INTERNET" />
49
+ <uses-permission android:name="android.permission.INTERNET" />
50
+ <application
51
+ android:allowBackup="true"
52
+ android:icon="@mipmap/ic_launcher"
53
+ android:label="@string/app_name"
54
+ android:roundIcon="@mipmap/ic_launcher_round"
55
+ android:supportsRtl="true"
56
+ android:theme="@style/AppTheme">
57
57
 
58
+ <activity android:name=".MainActivity">
59
+ <intent-filter>
60
+
61
+ <action android:name="android.intent.action.MAIN" />
62
+
63
+ <category android:name="android.intent.category.LAUNCHER" />
64
+
65
+ </intent-filter>
66
+ </activity>
67
+ </application>
68
+
69
+ </manifest>
58
70
  ```
59
71
  ###【MainActivity.java】
60
72
 
@@ -90,12 +102,12 @@
90
102
  ###【AsyncHttpRequest.java】
91
103
 
92
104
  ```java
105
+ package com.example.ddd;
106
+
93
107
  import android.app.Activity;
94
108
  import android.os.AsyncTask;
95
109
  import android.widget.TextView;
96
-
97
110
  import com.example.ddd.R;
98
-
99
111
  import org.json.JSONException;
100
112
  import org.json.JSONObject;
101
113
  import java.io.BufferedReader;

4

参照リンクも増やしました。

2020/11/29 05:10

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  #androidStudioで天気予報のアプリを作りたいのですが、シンボルが見つかりませんとエラーが出ます。どうかお力お貸しして頂けないでしょうか。
2
- ####[参照]https://tech-blog.rakus.co.jp/entry/android-studio/weather-hacks
2
+ ####[参照][天気予報のアプリ](https://tech-blog.rakus.co.jp/entry/android-studio/weather-hacks)
3
3
  ## エラーメッセージ
4
4
 
5
5
 

3

参照リンクも増やしました。

2020/11/27 09:46

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,16 +1,16 @@
1
1
  #androidStudioで天気予報のアプリを作りたいのですが、シンボルが見つかりませんとエラーが出ます。どうかお力お貸しして頂けないでしょうか。
2
- ####[リンク](https://tech-blog.rakus.co.jp/entry/android-studio/weather-)hacks)
2
+ ####[参照](https://tech-blog.rakus.co.jp/entry/android-studio/weather-)hacks)
3
3
  ## エラーメッセージ
4
4
 
5
5
 
6
6
 
7
+ ```
7
- new AsyncHttpRequest(result.this).execute(new URL("http://weather.livedoor.com/forecast/webservice/json/v1?city=270000"));
8
+ new AsyncHttpRequest(result.this).execute(new URL("http://weather.livedoor.com/forecast/webservice/json/v1?city=270000"));
8
9
  ^
9
10
  シンボル: クラス AsyncHttpRequest
10
11
  場所: クラス MainActivity
12
+ ```
11
13
 
12
-
13
- ### 該当のソースコード
14
14
  ###【activity_main.xml】
15
15
 
16
16
  ```xml

2

参照リンクも増やしました。

2020/11/27 09:40

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  #androidStudioで天気予報のアプリを作りたいのですが、シンボルが見つかりませんとエラーが出ます。どうかお力お貸しして頂けないでしょうか。
2
- ####[参照](https://tech-blog.rakus.co.jp/entry/android-studio/weather-)hacks)
2
+ ####[リンク](https://tech-blog.rakus.co.jp/entry/android-studio/weather-)hacks)
3
3
  ## エラーメッセージ
4
4
 
5
5
 

1

マークダウン記法を用いて読みやすくしました。

2020/11/27 09:33

投稿

shinmo
shinmo

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,18 +1,19 @@
1
- ### 前提・実現したいこと
2
- androidStudioで天気予報のアプリを作りたいのですが、シンボルが見つかりませんとエラーが出ます。どうかお力お貸しして頂けないでしょうか。
1
+ #androidStudioで天気予報のアプリを作りたいのですが、シンボルが見つかりませんとエラーが出ます。どうかお力お貸しして頂けないでしょうか。
3
- 参照(https://tech-blog.rakus.co.jp/entry/android-studio/weather-)hacks)
2
+ ####[参照](https://tech-blog.rakus.co.jp/entry/android-studio/weather-)hacks)
4
- ### 発生している問題・エラーメッセージ
3
+ ## エラーメッセージ
5
4
 
6
- ```
5
+
6
+
7
7
  new AsyncHttpRequest(result.this).execute(new URL("http://weather.livedoor.com/forecast/webservice/json/v1?city=270000"));
8
8
  ^
9
9
  シンボル: クラス AsyncHttpRequest
10
10
  場所: クラス MainActivity
11
- ```
12
11
 
12
+
13
13
  ### 該当のソースコード
14
- 【activity_main.xml】
14
+ ###【activity_main.xml】
15
15
 
16
+ ```xml
16
17
  <?xml version="1.0" encoding="utf-8"?>
17
18
  <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
18
19
  xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -44,16 +45,20 @@
44
45
  android:layout_marginTop="160dp" />
45
46
 
46
47
  </androidx.constraintlayout.widget.ConstraintLayout>
48
+ ```
47
49
 
48
50
 
49
51
 
50
52
 
51
- 【AndroidManifest.xml】
53
+ ###【AndroidManifest.xml】
54
+ ```xml
52
55
  <!-- ネット接続を許可する -->
53
56
  <uses-permission android:name="android.permission.INTERNET" />
54
57
 
58
+ ```
55
- 【MainActivity.java】
59
+ ###【MainActivity.java】
56
60
 
61
+ ```java
57
62
  package com.example.ddd;
58
63
 
59
64
  import androidx.appcompat.app.AppCompatActivity;
@@ -80,9 +85,11 @@
80
85
  }
81
86
  }
82
87
  }
88
+ ```
83
89
 
84
- 【AsyncHttpRequest】
90
+ ###【AsyncHttpRequest.java
85
91
 
92
+ ```java
86
93
  import android.app.Activity;
87
94
  import android.os.AsyncTask;
88
95
  import android.widget.TextView;
@@ -178,4 +185,6 @@
178
185
  TextView tv = mainActivity.findViewById(R.id.messageTextView);
179
186
  tv.setText(result);
180
187
  }
181
- }
188
+ }
189
+
190
+ ```