Dec 24, 2013 Replies: 20 Hi folks Yet again a new library called RSProximityAlert. There is already one in esLocationManager, but mine will let you add multiple Proximity Alerts to locations instead of 1. A proximity alert is a broadcast you receive when the device detects that it has entered or exited the area surrounding the location you entered. API Documentation RSProximityAlert Author: XverhelstX Version: 1 RSProximityAlert Fields: EVENT_ID_INTENT_EXTRA As String KEY_PROXIMITY_ENTERING As String PROXIMITY_INTENT_ACTION As String Methods: AddProximityAlert (Longitude As Double, Latitude As Double, Radius As Float, Expiration As Long, EventID As Long, RequestCode As Int) As PendingIntent Set a proximity alert for the location given by the position (latitude, longitude) and the given radius. When the device detects that it has entered or exited the area surrounding the location, the given PendingIntent will be used to create an Intent to be fired. The fired Intent will have a boolean extra added with key KEY_PROXIMITY_ENTERING. If the value is true, the device is entering the proximity region; if false, it is exiting. Returns the pending intent. Save this intent in a map with the Eventid if you want to remove this ProximityAlert later. Initialize Initializes this RSProximityAlert library IsInitialized As Boolean RemoveProximityAlert (intent As PendingIntent) Removes the Proximity Alert. Permissions: android.permission.ACCESS_COARSE_LOCATION android.permission.ACCESS_FINE_LOCATION Click to expand... Manifest Editor Code: AddReceiverText(VirtualService, <intent-filter> <action android:name="com.rootsoft.rslocationmanager.PROXIMITY_ALERT" /> </intent-filter>) Initialize Code: dim mProximityAlert as RSProximityAlert mProximityAlert.Initialize Add a Proximity alert to a location Code: Dim pIntent As Object pIntent = mProximityAlert.AddProximityAlert(Longitude, Latitude, Radius, PROXIMITY_DEFAULT_EXPIRATION, EventId, EventId) mapProximityAlerts.Put(EventId, pIntent) Handle the intent in your StartService Code: 'Handles the intent. Private Sub HandleIntent(StartingIntent As Intent) If StartingIntent.Action = mProximityAlert.PROXIMITY_INTENT_ACTION Then EventId = StartingIntent.GetExtra(mProximityAlert.EVENT_ID_INTENT_EXTRA) Entering = StartingIntent.GetExtra(mProximityAlert.KEY_PROXIMITY_ENTERING) If Entering Then ProximityEntered(EventId) Else ProximityLeft(EventId) End If End If End Sub Code: 'The user is entering a spot. Public Sub ProximityEntered (EventId As Long) Log("Entering Proximity Area: " & EventId) End Sub 'The user is leaving a spot. Public Sub ProximityLeft (EventId As Long) Log("Leaving a Proximity Area: " & EventId) End Sub Removing a Proximity alert can be done by setting the experation or removing the PendingIntent. This is why you should save the PendingIntent together with the EventId in a map. Kind regards, Tomas Attachments RSProximityAlert.zip RSProximityAlert.zip 3.4 KB · Views: 834 Click to expand...
Hi folks Yet again a new library called RSProximityAlert. There is already one in esLocationManager, but mine will let you add multiple Proximity Alerts to locations instead of 1. A proximity alert is a broadcast you receive when the device detects that it has entered or exited the area surrounding the location you entered. API Documentation RSProximityAlert Author: XverhelstX Version: 1 RSProximityAlert Fields: EVENT_ID_INTENT_EXTRA As String KEY_PROXIMITY_ENTERING As String PROXIMITY_INTENT_ACTION As String Methods: AddProximityAlert (Longitude As Double, Latitude As Double, Radius As Float, Expiration As Long, EventID As Long, RequestCode As Int) As PendingIntent Set a proximity alert for the location given by the position (latitude, longitude) and the given radius. When the device detects that it has entered or exited the area surrounding the location, the given PendingIntent will be used to create an Intent to be fired. The fired Intent will have a boolean extra added with key KEY_PROXIMITY_ENTERING. If the value is true, the device is entering the proximity region; if false, it is exiting. Returns the pending intent. Save this intent in a map with the Eventid if you want to remove this ProximityAlert later. Initialize Initializes this RSProximityAlert library IsInitialized As Boolean RemoveProximityAlert (intent As PendingIntent) Removes the Proximity Alert. Permissions: android.permission.ACCESS_COARSE_LOCATION android.permission.ACCESS_FINE_LOCATION Click to expand... Manifest Editor Code: AddReceiverText(VirtualService, <intent-filter> <action android:name="com.rootsoft.rslocationmanager.PROXIMITY_ALERT" /> </intent-filter>) Initialize Code: dim mProximityAlert as RSProximityAlert mProximityAlert.Initialize Add a Proximity alert to a location Code: Dim pIntent As Object pIntent = mProximityAlert.AddProximityAlert(Longitude, Latitude, Radius, PROXIMITY_DEFAULT_EXPIRATION, EventId, EventId) mapProximityAlerts.Put(EventId, pIntent) Handle the intent in your StartService Code: 'Handles the intent. Private Sub HandleIntent(StartingIntent As Intent) If StartingIntent.Action = mProximityAlert.PROXIMITY_INTENT_ACTION Then EventId = StartingIntent.GetExtra(mProximityAlert.EVENT_ID_INTENT_EXTRA) Entering = StartingIntent.GetExtra(mProximityAlert.KEY_PROXIMITY_ENTERING) If Entering Then ProximityEntered(EventId) Else ProximityLeft(EventId) End If End If End Sub Code: 'The user is entering a spot. Public Sub ProximityEntered (EventId As Long) Log("Entering Proximity Area: " & EventId) End Sub 'The user is leaving a spot. Public Sub ProximityLeft (EventId As Long) Log("Leaving a Proximity Area: " & EventId) End Sub Removing a Proximity alert can be done by setting the experation or removing the PendingIntent. This is why you should save the PendingIntent together with the EventId in a map. Kind regards, Tomas
B bluedude Well-Known Member Licensed User Longtime User Dec 27, 2013 #2 Interesting, a few questions: - What do you mean by handle intent in StartService? Do you mean in a service in the service creation part? - how many proximity events can it handle? - how to remove a pending intent? Would this work with the Fluffy location stuff? Cheers,
Interesting, a few questions: - What do you mean by handle intent in StartService? Do you mean in a service in the service creation part? - how many proximity events can it handle? - how to remove a pending intent? Would this work with the Fluffy location stuff? Cheers,
XverhelstX Well-Known Member Licensed User Longtime User Dec 27, 2013 #3 bluedude said: Interesting, a few questions: - What do you mean by handle intent in StartService? Do you mean in a service in the service creation part? - how many proximity events can it handle? - how to remove a pending intent? Would this work with the Fluffy location stuff? Cheers, Click to expand... 1. Copy the HandleIntent to your Service_Start sub and pass the StartingIntent parameter. A broadcast intent is sent when entering or leaving the proximity. 2. I have no idea. I think unlimited. 3. Store the pendingintent in a map with EventId as the key. You can call ProximityAlert.RemoveProximityAlert to remove one. Just pass the PendingIntent from the map as parameter 4. Yes, this is why I ported it as i'm using it in a app of my own.
bluedude said: Interesting, a few questions: - What do you mean by handle intent in StartService? Do you mean in a service in the service creation part? - how many proximity events can it handle? - how to remove a pending intent? Would this work with the Fluffy location stuff? Cheers, Click to expand... 1. Copy the HandleIntent to your Service_Start sub and pass the StartingIntent parameter. A broadcast intent is sent when entering or leaving the proximity. 2. I have no idea. I think unlimited. 3. Store the pendingintent in a map with EventId as the key. You can call ProximityAlert.RemoveProximityAlert to remove one. Just pass the PendingIntent from the map as parameter 4. Yes, this is why I ported it as i'm using it in a app of my own.
B bluedude Well-Known Member Licensed User Longtime User Dec 30, 2013 #4 Mmmm, still a little clueless about how to implement this. The service is started by a broadcast? What is the VirtualService in the manifest? Is this the service I create myself? What location solution needs to be implemented to get this working? GPS, WIFI or? A sample would help
Mmmm, still a little clueless about how to implement this. The service is started by a broadcast? What is the VirtualService in the manifest? Is this the service I create myself? What location solution needs to be implemented to get this working? GPS, WIFI or? A sample would help
XverhelstX Well-Known Member Licensed User Longtime User Dec 30, 2013 #5 The service is started by a broadcast? Click to expand... Yes, whenever the OS finds that you are in that proximity, it will send a broadcast to you own service and starts it (Here VirtualService) You can use any location library, and just for any location you find (with GPS for instance _LocationChanged) you can add a proximityalert on that location. Just change your manifest. Add the handleintent sub in your servce_create sub and adds the ProximityEntered and ProximityLeft subs. These are events when called when leaving or entering the area.
The service is started by a broadcast? Click to expand... Yes, whenever the OS finds that you are in that proximity, it will send a broadcast to you own service and starts it (Here VirtualService) You can use any location library, and just for any location you find (with GPS for instance _LocationChanged) you can add a proximityalert on that location. Just change your manifest. Add the handleintent sub in your servce_create sub and adds the ProximityEntered and ProximityLeft subs. These are events when called when leaving or entering the area.
K knifenine Member Licensed User Longtime User Feb 14, 2014 #6 Please request a sample. XverhelstX Regard.
Olaan Expert Licensed User Longtime User Feb 18, 2014 #7 Hi Tomas,or others Where is virtualservice_br Module? I cann't see it. Attachments TestRSProximityAlert.zip TestRSProximityAlert.zip 5.9 KB · Views: 632 Last edited: Feb 18, 2014
merlin2049er Well-Known Member Licensed User Longtime User Nov 11, 2014 #9 Hey, cool. I guess this would work if you were to pair it up with a bluetooth beacon.
Croïd Active Member Licensed User Longtime User Dec 21, 2014 #10 Thomas, Please, you have an example to understand the process ? How possible put notification near to a destination ? Thanks for your help Attachments rs2.zip rs2.zip 7.7 KB · Views: 549
Thomas, Please, you have an example to understand the process ? How possible put notification near to a destination ? Thanks for your help
coslad Well-Known Member Licensed User Longtime User Feb 7, 2015 #11 HI XverhelstX in the add function what do you mean for : Expiration As Long ? EventID As Long ? We decide the eventid number ? RequestCode As Int ? Radius As Float ? Is radius in centimeter , meter, km ? Thanks !!
HI XverhelstX in the add function what do you mean for : Expiration As Long ? EventID As Long ? We decide the eventid number ? RequestCode As Int ? Radius As Float ? Is radius in centimeter , meter, km ? Thanks !!
coslad Well-Known Member Licensed User Longtime User Feb 8, 2015 #12 It seems that this library is based on google service? May I wrong?
Croïd Active Member Licensed User Longtime User Feb 8, 2015 #13 Look this library (works well) https://www.b4x.com/android/forum/threads/expanded-location-manager-library.22500/
Look this library (works well) https://www.b4x.com/android/forum/threads/expanded-location-manager-library.22500/
coslad Well-Known Member Licensed User Longtime User Feb 8, 2015 #14 Thanks for the reply, but seems that whit exlocationmanager you can add a single Geofence location
b4xscripter Member Licensed User Longtime User Oct 4, 2015 #15 Hi! How is everything? Is updated the RSProximityAlert library? I would like to use it for my next project. Best regards
Hi! How is everything? Is updated the RSProximityAlert library? I would like to use it for my next project. Best regards
D Danbicky Member Licensed User Longtime User Oct 11, 2015 #16 This sounds Awesome, Please can you post an Example app showing us how to use this. I have an idea to use this for when I arrive home in the car to then send an MQTT message to disarm my alarm system and arm when I leave for work in the morning based on proximity. I have already developed the hardware and can control this through MQTT commands. Great work Dans
This sounds Awesome, Please can you post an Example app showing us how to use this. I have an idea to use this for when I arrive home in the car to then send an MQTT message to disarm my alarm system and arm when I leave for work in the morning based on proximity. I have already developed the hardware and can control this through MQTT commands. Great work Dans
b4xscripter Member Licensed User Longtime User Oct 11, 2015 #17 Hi all, I resolved it and implemented it in my new project using Fused Location and Node.js (with MongoDB). Works perfectly. By basic concerns to not implement all the "proximity logic" in the Android device but on the server are: - I am not sure that the multiple alarms are working - Sometimes the device be disconnected or even switched off. So the alert would "die". So I implemented the logic on the server and used the Android to "ping" to my server providing the geolocation coordinates... If anyone is interested, I would be happy to share my solution. Best regards
Hi all, I resolved it and implemented it in my new project using Fused Location and Node.js (with MongoDB). Works perfectly. By basic concerns to not implement all the "proximity logic" in the Android device but on the server are: - I am not sure that the multiple alarms are working - Sometimes the device be disconnected or even switched off. So the alert would "die". So I implemented the logic on the server and used the Android to "ping" to my server providing the geolocation coordinates... If anyone is interested, I would be happy to share my solution. Best regards
D Danbicky Member Licensed User Longtime User Oct 11, 2015 #18 Hi @ b4xscripter, Would be so cool if you could share your solution. Big thanks buddy Dans
D Danbicky Member Licensed User Longtime User Oct 15, 2015 #19 Hi XverhelstX Do you have a simple example demonstrating how this code works. I would really like to try this out with a Geo zone of 100 metres around my location and to control some device I have based on entering and exiting the Geo zone. Big thanks in advance for all your assistance. Dans
Hi XverhelstX Do you have a simple example demonstrating how this code works. I would really like to try this out with a Geo zone of 100 metres around my location and to control some device I have based on entering and exiting the Geo zone. Big thanks in advance for all your assistance. Dans
DonManfred Expert Licensed User Longtime User Oct 16, 2015 #20 Dont expect an answer from Xverhelst as he is no longer an active user.