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:
- 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.
- 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.
- 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.
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.