LoginSignup
41
42

More than 5 years have passed since last update.

AndroidのGeofenceを試してみました

Posted at

Androidのgoogle mapでGeofenceが使えるようになったとのことで、早速試してみました。
googleのサンプルを見ると、そんなに難しいことはしていませんでした。

参考
Creating and Monitoring Geofences

Google Play servicesの新機能 - LocationRequest(fused provider) と Geofence

googleのサンプルを参考にしつつ、google mapと組み合わせたものを作ってみましたので、何かの参考にしていただければと思います。

AndroidGeoFenceSample
*AndroidManifest.xmlのgoogle mapのAPIキーはご自分のキーに変えてください。

地図上でタップした位置から半径1000mがジオフェンスの範囲になります。
範囲に出入りすると通知バーにその情報が通知されます。

map_sample.png

位置情報はLocation Spooferとかで設定すればよいと思います。

*フェンスは1個しか置けませんし、タップした位置のピンは消えませんので。。

41
42
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
42