Giter VIP home page Giter VIP logo

android-geofencing's Introduction

Android Geofencing Sample

This sample has been deprecated/archived meaning it's read-only and it's no longer actively maintained (more details on archiving can be found here).

For another geofence sample, please check out the new github.com/android/location-samples repo. Thank you!

android-geofencing's People

Contributors

codingjeremy avatar google-automerger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-geofencing's Issues

Error Launching

When trying to launch this application the log shows 3 errors mainly complaining of no MainActivity in the wearable module.
Here is the Event Log:
Error while executing: am start -n "com.example.android.wearable.geofencing/com.example.android.wearable.geofencing.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.wearable.geofencing/.MainActivity }
Error type 3
Error: Activity class {com.example.android.wearable.geofencing/com.example.android.wearable.geofencing.MainActivity} does not exist.

Error while Launching activity

How to test with Mock Location

How can this be tested on an emulator?

Currently I have a Nexus 6P emulator running API 24 and Google Play Services, with the following config.ini file...

avd.ini.encoding=UTF-8
AvdId=Nexus_6P_API_24
abi.type=x86_64
avd.ini.displayname=Nexus 6P API 24
disk.dataPartition.size=800M
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=emulated
hw.camera.front=emulated
hw.cpu.arch=x86_64
hw.cpu.ncore=4
hw.dPad=no
hw.device.hash2=MD5:9b564b60b1aebee32c73ded9daa1e620
hw.device.manufacturer=Google
hw.device.name=Nexus 6P
hw.gps=yes
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.initialOrientation=Portrait
hw.keyboard=yes
hw.lcd.density=560
hw.mainKeys=no
hw.ramSize=1536
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images/android-24/google_apis/x86_64/
runtime.network.latency=none
runtime.network.speed=full
sdcard.size=100M
showDeviceFrame=yes
skin.dynamic=yes
skin.name=nexus_6p
skin.path=/Users/me/Library/Android/sdk/skins/nexus_6p
tag.display=Google APIs
tag.id=google_apis
vm.heapSize=64

I have tested with the "Send" location and the GPX file options in the extended controls with Google Maps running, and can see the user location dot moving indicating that the users location is changing. I have entered the coordinates that correspond to the 2 locations that have geofences, (Android building at 37.420092 -122.083648 and Yerba Buena at 37.784886 -122.402671), and can see the dot jumping to those locations, however no Geofence events are triggered.

I cannot seem to find any Geofence documentation talking about how it ties into mock location, nor can I find any information about whether the location that the extended controls tie into affect mock location or real location in the emulator. Using LocationServices.FusedLocationApi.setMockMode(googleApiClient, true) to see if that propogates to the LocationServices.GeofencingApi doesn't seem to have an effect.

The only buried detail that I could find to possibly point in the right direction was this note on the Location Strategies Page

Note: Providing mock location data is injected as GPS location data, so you must request location updates from GPS_PROVIDER in order for mock location data to work.

Geofences triggered only once

When I create a list of Geodences as on your example only the 1st event enter or exit is triggered until I reinitialize thE location client again, I used your exact sample code I don't have this issue with the older version of Google Play Services.

Is there something I need to tell the client after serving the 1st event on a geofence to continue listening?

Pending intent is removed

Your samples does not work. When register the Intent with:

private PendingIntent getGeofenceTransitionPendingIntent() {
| Intent intent = new Intent(this, GeofenceTransitionsIntentService.class);
| return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
| }

It triggers but after a while it stops. Why? (I do not reboot my mobile)

Also see:
#8

Using IntentServer for Toast yields "Handler on a dead thread" error

This code sample gives me errors:

02-05 12:16:01.464 W/MessageQueue( 5372): Handler (android.os.Handler) {128af18d} sending message to a Handler on a dead thread
02-05 12:16:01.464 W/MessageQueue( 5372): java.lang.IllegalStateException: Handler (android.os.Handler) {128af18d} sending message to a Handler on a dead thread
02-05 12:16:01.464 W/MessageQueue( 5372): at android.os.MessageQueue.enqueueMessage(MessageQueue.java:325)
02-05 12:16:01.464 W/MessageQueue( 5372): at android.os.Handler.enqueueMessage(Handler.java:631)
02-05 12:16:01.464 W/MessageQueue( 5372): at android.os.Handler.sendMessageAtTime(Handler.java:600)
02-05 12:16:01.464 W/MessageQueue( 5372): at android.os.Handler.sendMessageDelayed(Handler.java:570)
02-05 12:16:01.464 W/MessageQueue( 5372): at android.os.Handler.post(Handler.java:326)
02-05 12:16:01.464 W/MessageQueue( 5372): at android.widget.Toast$TN.hide(Toast.java:379)
02-05 12:16:01.464 W/MessageQueue( 5372): at android.app.ITransientNotification$Stub.onTransact(ITransientNotification.java:55)
02-05 12:16:01.464 W/MessageQueue( 5372): at android.os.Binder.execTransact(Binder.java:446)

I believe the problem is GeofenceTransitionsIntentService displays a Toast, but the IntentService thread is short-lived, just for the lifetime of handling the Intent. There's some discussion at http://stackoverflow.com/questions/4443278/toast-sending-message-to-a-handler-on-a-dead-thread

Fix is to wrap the Toast calls in a Runnable in GeofenceTransitionsIntentService:
mMainThreadHandler.post(new Runnable() {
@OverRide
public void run() {
Toast.makeText(GeofenceTransitionsIntentService.this,
getString(R.string.entering_geofence),
Toast.LENGTH_SHORT).show();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.