ESLibraryを使ってSensorDataListenerで定期的に位置情報を取得する
こんにちは。tsmsogn です。
今回は、ESLibrary の SensorDataListener を拡張して、定期的に位置情報を取得するサンプロを作ってみたいと思います。
tl;dr
作りました!
特徴は、以下のとおりです。
- LOCATION_ACCURACY_FINE
- 約1秒ごとに位置情報を取得(0秒間隔でアップデートするようにパッチを当てたものを使用していま す)*1
SensorDataとSensorDataManagerをdependenciesに追加
diff --git a/app/build.gradle b/app/build.gradle index 99d51b8..cd72de2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,5 +26,7 @@ dependencies { }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile 'com.github.tsmsogn:SensorManager:4e90e18' + compile 'com.github.tsmsogn:SensorDataManager:900c3a0' testCompile 'junit:junit:4.12' } diff --git a/build.gradle b/build.gradle index 1ea4bd0..345f00d 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,7 @@ buildscript { allprojects { repositories { jcenter() + maven { url 'https://jitpack.io' } } }
LocationDataListenerを作成
SensorDataListener を継承して作成します。