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

回答編集履歴

1

関数化した処理に上位のtry/catchを入れ忘れ。このように関数分割したことで同じ処理を2度書く必要があることがあるので注意が必要。

2021/03/26 13:46

投稿

rtazaki
rtazaki

スコア69

answer CHANGED
@@ -93,18 +93,22 @@
93
93
  }
94
94
  }
95
95
 
96
- private void moveCamera(){
96
+ private void moveCamera() {
97
+ try {
97
- if (isJapan(location.getLatitude(), location.getLongitude())) {
98
+ if (isJapan(location.getLatitude(), location.getLongitude())) {
98
- // [国内]
99
+ // [国内]
99
- mApplicationManager.getMap().clear();
100
+ mApplicationManager.getMap().clear();
100
- mApplicationManager.getCommunication().executeByConcurrentExecutor();
101
+ mApplicationManager.getCommunication().executeByConcurrentExecutor();
101
- // 現在位置に設定
102
+ // 現在位置に設定
102
- LatLng currentLocation = new LatLng(location.getLatitude(), location.getLongitude());
103
+ LatLng currentLocation = new LatLng(location.getLatitude(), location.getLongitude());
103
- mApplicationManager.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 16.0f));
104
+ mApplicationManager.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 16.0f));
104
- } else {
105
+ } else {
105
- // [海外]
106
+ // [海外]
106
- // 日本地図を表示
107
+ // 日本地図を表示
107
- mApplicationManager.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(defaultLocation, DEFAULT_ZOOM));
108
+ mApplicationManager.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(defaultLocation, DEFAULT_ZOOM));
109
+ }
110
+ } catch (SecurityException e) {
111
+ Log.e("Exception: %s", e.getMessage(), e);
108
112
  }
109
113
  }
110
114
  ```