-1

I am developing an application that will perform some operation once user enter into predefined area even if GPS is off or not available.

Issue : How to identify user has entered into that area(radius or accuracy of 500 to 700 meters).

Possible solution with pros & cons:

  1. Geofence : It will only work if GPS is on otherwise will not & even if GPS is on but there is no connectivity with satellite which is most likely as per the use-case of my application(in basement, travelling underground or in tunnel), geofence will not trigger. So cannot rely entirely on GPS.

Pros:

a. Will work if GPS is on & able to connect with satellite.

b. Will work even if mobile screen is off(i.e sleep mode)

Cons: a. Will not work if GPS is OFF.

b. Will not work in-case of connectivity issue like in basements, tunnel.

  1. addProximityAlert :can anyone please explain what is difference between addProximityAlert & geofencing? Which one is better? Is proximity alert trigger in following case:

a. When screen is off but GPS is on.

b. When GPS is off.

  1. Cell id from onCellLocationChanged(): As cannot rely completely on GPS(can be off or no connectivity) thought of using cellLocation. So I implemented MyPhoneStateListener extends PhoneStateListener, registered it with telephony services for PhoneStateListener.LISTEN_CELL_LOCATION & override onCellLocationChanged method.

I know cell id or tower ids of area where I want operation to be performed on entry so when onCellLocationChanged method is called I get cid from cellLocationobject & compare it with stored cell ids.

Problem is onCellLocationChanged method is not called when screen if off. Found that this method is also called in case of incoming & outgoing call, don't know reason it should only be called when cell location is changed. Anyone knows the reason?

Pros:

a. Will work even if GPS is OFF.

Cons:

a. onCellLocationChanged method is not called when screen if off(i.e sleep mode). It is also called when in case of incoming & outgoing call.

Tried holding partial wake lock still this method is not called. Someone has written start a service & request for location updates from network then even if screen is off onCellLocationChanged method will be called. Tried but still onCellLocationChanged is not called when screen is OFF.

  1. Created service that request for location updates from network after every 2 mins & min distance is 500 meters.

    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,1000 *60 *2,500,this);
    

Queries on 4th point:

a. Do we get location updates from network if screen is off.

b. When GPS is on getting location updates from network but when GPS is OFF not getting location updates from network. Not 100 percent sure about this point need to examine more. Please let me know what's behavior when we request location updates from network & GPS is off.

Asked too many question in one post but after exploring various options for 10-12 days couldn't able to find reliable solution that work even without GPS.

Thanks.

napster
  • 687
  • 1
  • 8
  • 18

1 Answers1

0

Disclosure: I work for Pathsense.

Although I haven't tested Google's geofence or Android's geofence (addProximityAlert()) without GPS on, I have tested Pathsense geofences extensively, and I know it will work with no GPS (not as accurately although).

However, if having a third-party library is out of the question, you can set a location update request (LocationManager.requestUpdates()) with a minTime of at least 30 seconds. This will decrease power consumption, and you can just do a distance calculation between the location you are monitoring and the locations given by the LocationManager, and perform whatever action you desire if it is greater than your monitoring region.

Pablo Baxter
  • 2,144
  • 1
  • 17
  • 36
  • Thanks for your reply @Pablo. PathSense if free or paid? What is accuracy radius of Pathsense. If it has accuracy of 700 to 800 meters without GPS will work for me. – napster Apr 15 '16 at 11:34
  • Yes, it is free, and I don't see an issue with it working on a geofence of that size. We support geofences as small as 50 meters, although I recommend having GPS on in that case. – Pablo Baxter Apr 15 '16 at 16:59
  • Appreciate your effort @Pablo. Will try PathSense before marking answer as helpful. Actually application am making should work even without GPS with proximity of 700-800 meters. Hope solution works. Cheers. – napster Apr 16 '16 at 09:20