質問編集履歴
5
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -276,11 +276,11 @@
|
|
276
276
|
|
277
277
|
|
278
278
|
|
279
|
-
private void start
|
279
|
+
private void startLocation() {
|
280
|
-
|
281
|
-
|
282
|
-
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
-
Log.d("
|
283
|
+
Log.d("StartLocation","呼ばれた");
|
284
284
|
|
285
285
|
initLocationService();
|
286
286
|
|
@@ -288,7 +288,7 @@
|
|
288
288
|
|
289
289
|
|
290
290
|
|
291
|
-
private void stop
|
291
|
+
private void stopLocation() {
|
292
292
|
|
293
293
|
Log.d("stopLocation","呼ばれた");
|
294
294
|
|
@@ -316,15 +316,15 @@
|
|
316
316
|
|
317
317
|
if(check.equals("start")){
|
318
318
|
|
319
|
-
start
|
319
|
+
startLocation();
|
320
|
-
|
320
|
+
|
321
|
-
Log.d("
|
321
|
+
Log.d("StartLocation","呼ぶ");
|
322
322
|
|
323
323
|
}else if(check.equals("stop")){
|
324
324
|
|
325
|
-
stop
|
325
|
+
stopLocation();
|
326
|
-
|
326
|
+
|
327
|
-
Log.d("
|
327
|
+
Log.d("StopLocation","呼ぶ");
|
328
328
|
|
329
329
|
}
|
330
330
|
|
@@ -406,7 +406,7 @@
|
|
406
406
|
|
407
407
|
}
|
408
408
|
|
409
|
-
};
|
409
|
+
};
|
410
410
|
|
411
411
|
ref.addChildEventListener(childEventListener);
|
412
412
|
|
4
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
4
4
|
|
5
|
-
の中で、start
|
5
|
+
の中で、startLocation()を呼び出そうとしても呼び出せません。
|
6
6
|
|
7
7
|
Serviceが途中で停止している気がするのですが、何が原因でしょうか?
|
8
8
|
|
3
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,7 +92,7 @@
|
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
-
|
95
|
+
|
96
96
|
|
97
97
|
|
98
98
|
|
@@ -280,7 +280,7 @@
|
|
280
280
|
|
281
281
|
|
282
282
|
|
283
|
-
Log.d("onStart
|
283
|
+
Log.d("onStartLocation","呼ばれた");
|
284
284
|
|
285
285
|
initLocationService();
|
286
286
|
|
@@ -290,7 +290,7 @@
|
|
290
290
|
|
291
291
|
private void stopFusedLocation() {
|
292
292
|
|
293
|
-
Log.d("stop
|
293
|
+
Log.d("stopLocation","呼ばれた");
|
294
294
|
|
295
295
|
//firebase.auth().signOut();これでログアウトはできるが、ログアウトはしない
|
296
296
|
|
@@ -318,13 +318,13 @@
|
|
318
318
|
|
319
319
|
startFusedLocation();
|
320
320
|
|
321
|
-
Log.d("onStart
|
321
|
+
Log.d("onStartLocation","呼ぶ");
|
322
322
|
|
323
323
|
}else if(check.equals("stop")){
|
324
324
|
|
325
325
|
stopFusedLocation();
|
326
326
|
|
327
|
-
Log.d("onStop
|
327
|
+
Log.d("onStopLocation","呼ぶ");
|
328
328
|
|
329
329
|
}
|
330
330
|
|
@@ -406,7 +406,7 @@
|
|
406
406
|
|
407
407
|
}
|
408
408
|
|
409
|
-
};
|
409
|
+
};
|
410
410
|
|
411
411
|
ref.addChildEventListener(childEventListener);
|
412
412
|
|
@@ -418,6 +418,4 @@
|
|
418
418
|
|
419
419
|
|
420
420
|
|
421
|
-
|
422
|
-
|
423
421
|
```
|
2
コードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,12 +26,8 @@
|
|
26
26
|
|
27
27
|
import android.os.IBinder;
|
28
28
|
|
29
|
-
//import com.google.android.gms.location.LocationListener;
|
30
|
-
|
31
29
|
import android.location.LocationListener;
|
32
30
|
|
33
|
-
import com.google.android.gms.common.api.GoogleApiClient;
|
34
|
-
|
35
31
|
import android.content.pm.PackageManager;
|
36
32
|
|
37
33
|
import android.location.Location;
|
@@ -42,12 +38,6 @@
|
|
42
38
|
|
43
39
|
import android.util.Log;
|
44
40
|
|
45
|
-
import android.widget.TextView;
|
46
|
-
|
47
|
-
import com.google.android.gms.location.FusedLocationProviderApi;
|
48
|
-
|
49
|
-
import com.google.android.gms.location.LocationRequest;
|
50
|
-
|
51
41
|
import com.google.android.gms.common.ConnectionResult;
|
52
42
|
|
53
43
|
import com.google.firebase.database.ChildEventListener;
|
@@ -64,11 +54,7 @@
|
|
64
54
|
|
65
55
|
|
66
56
|
|
67
|
-
public class GpsService extends Service implements
|
57
|
+
public class GpsService extends Service implements LocationListener{
|
68
|
-
|
69
|
-
GoogleApiClient.ConnectionCallbacks,
|
70
|
-
|
71
|
-
GoogleApiClient.OnConnectionFailedListener,LocationListener{
|
72
58
|
|
73
59
|
|
74
60
|
|
@@ -106,25 +92,245 @@
|
|
106
92
|
|
107
93
|
|
108
94
|
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
public GpsService() {
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
//serviceだからいらないかも removeupdatesは必要
|
106
|
+
|
107
|
+
// @Override
|
108
|
+
|
109
|
+
// protected void onPause(){
|
110
|
+
|
111
|
+
// super.onPause();
|
112
|
+
|
113
|
+
// locationManager.removeUpdates(this);
|
114
|
+
|
115
|
+
// mLocationManager.removeUpdates(listener);
|
116
|
+
|
117
|
+
// }
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
protected void initLocationService() {
|
122
|
+
|
123
|
+
Log.v("initLocationService()", "呼ばれた");
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
128
|
+
|
129
|
+
return;
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
134
|
+
|
135
|
+
return;
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
Criteria criteria = new Criteria();
|
142
|
+
|
143
|
+
criteria.setAccuracy(Criteria.ACCURACY_FINE); //setAccuracyは内部では、https://stackoverflow.com/a/17874592/1709287の用にHorizontalAccuracyの設定に変換されている。
|
144
|
+
|
145
|
+
criteria.setPowerRequirement(Criteria.POWER_HIGH);
|
146
|
+
|
147
|
+
criteria.setAltitudeRequired(false);
|
148
|
+
|
149
|
+
criteria.setSpeedRequired(true);
|
150
|
+
|
151
|
+
criteria.setCostAllowed(true);
|
152
|
+
|
153
|
+
criteria.setBearingRequired(false);
|
154
|
+
|
155
|
+
criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
|
156
|
+
|
157
|
+
criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
// locationManager.registerGnssStatusCallback()
|
162
|
+
|
163
|
+
// locationManager.requestLocationUpdates(gpsFreqInMillis, gpsFreqInDistance, criteria, this, null);
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
168
|
+
|
169
|
+
String bestProvider = locationManager.getBestProvider(criteria, true);
|
170
|
+
|
171
|
+
locationManager.requestLocationUpdates(bestProvider, 6000, 1, this);
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
@Override
|
178
|
+
|
179
|
+
public void onLocationChanged(Location location) {
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
Log.v("onLocationChanged", "呼ばれた");
|
184
|
+
|
185
|
+
refreshGeoLocation(location);
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
//LocationListenerのメソッド
|
192
|
+
|
193
|
+
@Override
|
194
|
+
|
195
|
+
public void onStatusChanged(String provider, int status, Bundle extras) {
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
@Override
|
204
|
+
|
205
|
+
public void onProviderEnabled(String provider) {
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
@Override
|
214
|
+
|
215
|
+
public void onProviderDisabled(String provider) {
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
//ここまで
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
// 位置情報のリスナーを取得して登録する
|
230
|
+
|
231
|
+
//sensorEventListener = new GpsLocationListener(sensorValueTextView);
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
// public class LocationServiceBinder extends Binder {
|
238
|
+
|
239
|
+
// public com.google.android.exoplayer2.demo.GpsService getService() {
|
240
|
+
|
241
|
+
// return com.google.android.exoplayer2.demo.GpsService.this;
|
242
|
+
|
243
|
+
// }
|
244
|
+
|
245
|
+
// }
|
246
|
+
|
247
|
+
protected void refreshGeoLocation(Location location){
|
248
|
+
|
249
|
+
Log.v("refreshGeoLocation","呼ばれた");
|
250
|
+
|
251
|
+
String user = FirebaseAuth.getInstance().getCurrentUser().getUid();
|
252
|
+
|
253
|
+
DatabaseReference ref = database.getReference().child("users").child(user);
|
254
|
+
|
255
|
+
DatabaseReference latitudeRef = ref.child("latitude");
|
256
|
+
|
257
|
+
DatabaseReference longitudeRef = ref.child("longitude");
|
258
|
+
|
259
|
+
latitudeRef.setValue(location.getLatitude());
|
260
|
+
|
261
|
+
longitudeRef.setValue(location.getLongitude());
|
262
|
+
|
263
|
+
}
|
264
|
+
|
109
265
|
|
110
266
|
|
111
267
|
@Override
|
112
268
|
|
113
|
-
public
|
269
|
+
public IBinder onBind(Intent intent) {
|
114
|
-
|
270
|
+
|
115
|
-
Log.
|
271
|
+
Log.v("onBind","呼ばれた");
|
272
|
+
|
116
|
-
|
273
|
+
throw new UnsupportedOperationException("Not yet implemented");
|
274
|
+
|
117
|
-
}
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
118
|
-
|
279
|
+
private void startFusedLocation() {
|
280
|
+
|
281
|
+
|
282
|
+
|
119
|
-
|
283
|
+
Log.d("onStartFusedLocation","呼ばれた");
|
284
|
+
|
285
|
+
initLocationService();
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
private void stopFusedLocation() {
|
292
|
+
|
293
|
+
Log.d("stopFusedLocation","呼ばれた");
|
294
|
+
|
295
|
+
//firebase.auth().signOut();これでログアウトはできるが、ログアウトはしない
|
296
|
+
|
297
|
+
database.goOffline();
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
//private final LocationListener listener = new LocationListener() {
|
120
304
|
|
121
305
|
@Override
|
122
306
|
|
123
|
-
public
|
307
|
+
public int onStartCommand(Intent intent, int flags, int startId) {
|
308
|
+
|
124
|
-
|
309
|
+
Log.d("onStartCommand","呼ばれた");
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
String check =intent.getStringExtra("start/stop");
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
if(check.equals("start")){
|
318
|
+
|
319
|
+
startFusedLocation();
|
320
|
+
|
321
|
+
Log.d("onStartFusedLocation","呼ぶ");
|
322
|
+
|
323
|
+
}else if(check.equals("stop")){
|
324
|
+
|
325
|
+
stopFusedLocation();
|
326
|
+
|
125
|
-
Log.d("on
|
327
|
+
Log.d("onStopFusedLocation","呼ぶ");
|
328
|
+
|
126
|
-
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
|
127
|
-
|
333
|
+
return super.onStartCommand(intent, flags, startId);
|
128
334
|
|
129
335
|
}
|
130
336
|
|
@@ -132,278 +338,6 @@
|
|
132
338
|
|
133
339
|
@Override
|
134
340
|
|
135
|
-
public void onConnectionFailed(ConnectionResult connectionResult) {
|
136
|
-
|
137
|
-
Log.v("onConnectionFailed()","呼ばれた");
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
if (mResolvingError) {
|
142
|
-
|
143
|
-
// Already attempting to resolve an error.
|
144
|
-
|
145
|
-
Log.d("", "Already attempting to resolve an error");
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
return;
|
150
|
-
|
151
|
-
} else if (connectionResult.hasResolution()) {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
} else {
|
156
|
-
|
157
|
-
mResolvingError = true;
|
158
|
-
|
159
|
-
}
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
public GpsService() {
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
//serviceだからいらないかも removeupdatesは必要
|
172
|
-
|
173
|
-
// @Override
|
174
|
-
|
175
|
-
// protected void onPause(){
|
176
|
-
|
177
|
-
// super.onPause();
|
178
|
-
|
179
|
-
// locationManager.removeUpdates(this);
|
180
|
-
|
181
|
-
// mLocationManager.removeUpdates(listener);
|
182
|
-
|
183
|
-
// }
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
protected void initLocationService() {
|
188
|
-
|
189
|
-
Log.v("initLocationService()", "呼ばれた");
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
194
|
-
|
195
|
-
return;
|
196
|
-
|
197
|
-
}
|
198
|
-
|
199
|
-
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
200
|
-
|
201
|
-
return;
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
Criteria criteria = new Criteria();
|
208
|
-
|
209
|
-
criteria.setAccuracy(Criteria.ACCURACY_FINE); //setAccuracyは内部では、https://stackoverflow.com/a/17874592/1709287の用にHorizontalAccuracyの設定に変換されている。
|
210
|
-
|
211
|
-
criteria.setPowerRequirement(Criteria.POWER_HIGH);
|
212
|
-
|
213
|
-
criteria.setAltitudeRequired(false);
|
214
|
-
|
215
|
-
criteria.setSpeedRequired(true);
|
216
|
-
|
217
|
-
criteria.setCostAllowed(true);
|
218
|
-
|
219
|
-
criteria.setBearingRequired(false);
|
220
|
-
|
221
|
-
criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
|
222
|
-
|
223
|
-
criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
// locationManager.registerGnssStatusCallback()
|
228
|
-
|
229
|
-
// locationManager.requestLocationUpdates(gpsFreqInMillis, gpsFreqInDistance, criteria, this, null);
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
234
|
-
|
235
|
-
String bestProvider = locationManager.getBestProvider(criteria, true);
|
236
|
-
|
237
|
-
locationManager.requestLocationUpdates(bestProvider, 6000, 1, this);
|
238
|
-
|
239
|
-
}
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
@Override
|
244
|
-
|
245
|
-
public void onLocationChanged(Location location) {
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
Log.v("onLocationChanged", "呼ばれた");
|
250
|
-
|
251
|
-
refreshGeoLocation(location);
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
//LocationListenerのメソッド
|
258
|
-
|
259
|
-
@Override
|
260
|
-
|
261
|
-
public void onStatusChanged(String provider, int status, Bundle extras) {
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
@Override
|
270
|
-
|
271
|
-
public void onProviderEnabled(String provider) {
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
}
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
@Override
|
280
|
-
|
281
|
-
public void onProviderDisabled(String provider) {
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
}
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
//ここまで
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
// 位置情報のリスナーを取得して登録する
|
296
|
-
|
297
|
-
//sensorEventListener = new GpsLocationListener(sensorValueTextView);
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
public class LocationServiceBinder extends Binder {
|
304
|
-
|
305
|
-
public com.google.android.exoplayer2.demo.GpsService getService() {
|
306
|
-
|
307
|
-
return com.google.android.exoplayer2.demo.GpsService.this;
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
protected void refreshGeoLocation(Location location){
|
314
|
-
|
315
|
-
Log.v("refreshGeoLocation","呼ばれた");
|
316
|
-
|
317
|
-
String user = FirebaseAuth.getInstance().getCurrentUser().getUid();
|
318
|
-
|
319
|
-
DatabaseReference ref = database.getReference().child("users").child(user);
|
320
|
-
|
321
|
-
DatabaseReference latitudeRef = ref.child("latitude");
|
322
|
-
|
323
|
-
DatabaseReference longitudeRef = ref.child("longitude");
|
324
|
-
|
325
|
-
latitudeRef.setValue(location.getLatitude());
|
326
|
-
|
327
|
-
longitudeRef.setValue(location.getLongitude());
|
328
|
-
|
329
|
-
}
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
@Override
|
334
|
-
|
335
|
-
public IBinder onBind(Intent intent) {
|
336
|
-
|
337
|
-
Log.v("onBind","呼ばれた");
|
338
|
-
|
339
|
-
throw new UnsupportedOperationException("Not yet implemented");
|
340
|
-
|
341
|
-
}
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
private void startFusedLocation() {
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
Log.d("onStartFusedLocation","呼ばれた");
|
350
|
-
|
351
|
-
initLocationService();
|
352
|
-
|
353
|
-
}
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
private void stopFusedLocation() {
|
358
|
-
|
359
|
-
Log.d("stopFusedLocation","呼ばれた");
|
360
|
-
|
361
|
-
//firebase.auth().signOut();これでログアウトはできるが、ログアウトはしない
|
362
|
-
|
363
|
-
database.goOffline();
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
//private final LocationListener listener = new LocationListener() {
|
370
|
-
|
371
|
-
@Override
|
372
|
-
|
373
|
-
public int onStartCommand(Intent intent, int flags, int startId) {
|
374
|
-
|
375
|
-
Log.d("onStartCommand","呼ばれた");
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
String check =intent.getStringExtra("start/stop");
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
if(check.equals("start")){
|
384
|
-
|
385
|
-
startFusedLocation();
|
386
|
-
|
387
|
-
Log.d("onStartFusedLocation","呼ぶ");
|
388
|
-
|
389
|
-
}else if(check.equals("stop")){
|
390
|
-
|
391
|
-
stopFusedLocation();
|
392
|
-
|
393
|
-
Log.d("onStopFusedLocation","呼ぶ");
|
394
|
-
|
395
|
-
}
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
return super.onStartCommand(intent, flags, startId);
|
400
|
-
|
401
|
-
}
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
@Override
|
406
|
-
|
407
341
|
public void onDestroy() {
|
408
342
|
|
409
343
|
super.onDestroy();
|
@@ -484,4 +418,6 @@
|
|
484
418
|
|
485
419
|
|
486
420
|
|
421
|
+
|
422
|
+
|
487
423
|
```
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -76,9 +76,7 @@
|
|
76
76
|
|
77
77
|
final FirebaseDatabase database = FirebaseDatabase.getInstance();
|
78
78
|
|
79
|
-
private
|
79
|
+
private LocationListener sensorEventListener; // onPause()
|
80
|
-
|
81
|
-
private DatabaseReference mDatabaseRef;
|
82
80
|
|
83
81
|
|
84
82
|
|
@@ -110,8 +108,6 @@
|
|
110
108
|
|
111
109
|
|
112
110
|
|
113
|
-
|
114
|
-
|
115
111
|
@Override
|
116
112
|
|
117
113
|
public void onConnected(Bundle bundle) {
|
@@ -166,8 +162,6 @@
|
|
166
162
|
|
167
163
|
|
168
164
|
|
169
|
-
|
170
|
-
|
171
165
|
public GpsService() {
|
172
166
|
|
173
167
|
}
|
@@ -184,15 +178,15 @@
|
|
184
178
|
|
185
179
|
// locationManager.removeUpdates(this);
|
186
180
|
|
181
|
+
// mLocationManager.removeUpdates(listener);
|
182
|
+
|
187
183
|
// }
|
188
184
|
|
189
185
|
|
190
186
|
|
191
|
-
|
192
|
-
|
193
|
-
protected void initLocationService(){
|
187
|
+
protected void initLocationService() {
|
194
|
-
|
188
|
+
|
195
|
-
Log.v("initLocationService()","呼ばれた");
|
189
|
+
Log.v("initLocationService()", "呼ばれた");
|
196
190
|
|
197
191
|
|
198
192
|
|
@@ -210,8 +204,6 @@
|
|
210
204
|
|
211
205
|
|
212
206
|
|
213
|
-
|
214
|
-
|
215
207
|
Criteria criteria = new Criteria();
|
216
208
|
|
217
209
|
criteria.setAccuracy(Criteria.ACCURACY_FINE); //setAccuracyは内部では、https://stackoverflow.com/a/17874592/1709287の用にHorizontalAccuracyの設定に変換されている。
|
@@ -242,21 +234,67 @@
|
|
242
234
|
|
243
235
|
String bestProvider = locationManager.getBestProvider(criteria, true);
|
244
236
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
locationManager.requestLocationUpdates(bestProvider,6000,1,this);
|
237
|
+
locationManager.requestLocationUpdates(bestProvider, 6000, 1, this);
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
238
|
+
|
255
|
-
}
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
256
|
-
|
243
|
+
@Override
|
244
|
+
|
245
|
+
public void onLocationChanged(Location location) {
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
Log.v("onLocationChanged", "呼ばれた");
|
250
|
+
|
251
|
+
refreshGeoLocation(location);
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
//LocationListenerのメソッド
|
258
|
+
|
259
|
+
@Override
|
260
|
+
|
261
|
+
public void onStatusChanged(String provider, int status, Bundle extras) {
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
@Override
|
270
|
+
|
271
|
+
public void onProviderEnabled(String provider) {
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
@Override
|
280
|
+
|
281
|
+
public void onProviderDisabled(String provider) {
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
//ここまで
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
// 位置情報のリスナーを取得して登録する
|
296
|
+
|
257
|
-
//
|
297
|
+
//sensorEventListener = new GpsLocationListener(sensorValueTextView);
|
258
|
-
|
259
|
-
|
260
298
|
|
261
299
|
|
262
300
|
|
@@ -272,20 +310,10 @@
|
|
272
310
|
|
273
311
|
}
|
274
312
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
313
|
protected void refreshGeoLocation(Location location){
|
280
314
|
|
281
|
-
|
282
|
-
|
283
315
|
Log.v("refreshGeoLocation","呼ばれた");
|
284
316
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
317
|
String user = FirebaseAuth.getInstance().getCurrentUser().getUid();
|
290
318
|
|
291
319
|
DatabaseReference ref = database.getReference().child("users").child(user);
|
@@ -302,8 +330,6 @@
|
|
302
330
|
|
303
331
|
|
304
332
|
|
305
|
-
|
306
|
-
|
307
333
|
@Override
|
308
334
|
|
309
335
|
public IBinder onBind(Intent intent) {
|
@@ -318,6 +344,8 @@
|
|
318
344
|
|
319
345
|
private void startFusedLocation() {
|
320
346
|
|
347
|
+
|
348
|
+
|
321
349
|
Log.d("onStartFusedLocation","呼ばれた");
|
322
350
|
|
323
351
|
initLocationService();
|
@@ -376,60 +404,6 @@
|
|
376
404
|
|
377
405
|
@Override
|
378
406
|
|
379
|
-
public void onLocationChanged (Location location){
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
Log.v("onLocationChanged","呼ばれた");
|
384
|
-
|
385
|
-
refreshGeoLocation(location);
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
}
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
//LocationListenerのメソッド
|
396
|
-
|
397
|
-
@Override
|
398
|
-
|
399
|
-
public void onStatusChanged(String provider, int status, Bundle extras) {
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
}
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
@Override
|
408
|
-
|
409
|
-
public void onProviderEnabled(String provider) {
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
}
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
@Override
|
418
|
-
|
419
|
-
public void onProviderDisabled(String provider) {
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
}
|
424
|
-
|
425
|
-
//ここまで
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
@Override
|
432
|
-
|
433
407
|
public void onDestroy() {
|
434
408
|
|
435
409
|
super.onDestroy();
|
@@ -504,12 +478,10 @@
|
|
504
478
|
|
505
479
|
}
|
506
480
|
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
481
|
}
|
512
482
|
|
513
483
|
|
514
484
|
|
485
|
+
|
486
|
+
|
515
487
|
```
|