Introduction: Proximity Alert (Geofencing) TfCD
Setting up proximity alerts on your Android
This instructables page has been written for the TfCD course
of the TUDelft, therefore the example I have programmed has been set to trigger proximity alerts near my faculty. If everything goes correctly, it will look a bit like that.
Nowadays, many mobile devices feature GPS however the degree to which a user can access this feature is limited. There are already a lot of apps out there that use GPS in one way or another, but harnessing GPS yourself is still a treacherous path to take.
Fortunately, this step-by-step tutorial will show you the highlights of implementing GPS coordinates in your own app and the main pointers that you must not forget!
Note: This is not a complete app, this instructable lists the needed information to be able to add it in your own app.
Step 1: Proximity Alerts & Code
Hold up! Let’s back up for a bit: What are proximity alerts?
You visit your grandma once in a few months in her nursing home, but you always forget the floor number! By importing the coordinates of your grandma’s nursing home, you can make it so that when you are within a set distance (e.g. 20 meters) a notification will pop-up and tell you: “Floor 3, room 305”.
How about the fact that you have a discount coupon for your favourite store, but you always forget to bring it with you? Set the app so that you get a reminder as soon as you walk in the store stating: “Your coupon code is 3S24T.”
Now let's get started!
Step 2: #1 Installing Android Studio & SDK Packages
You’re going to need some software… But good news: it’s free!
Follow the link and click the download button. Agree with the terms & conditions (which we haven’t really read) and continue.
When the folder has been downloaded, launch the .exe file from that folder. The setup wizard will guide you through the process and if you need more help, I’ll kindly refer you to the explanation of Android Studio:
Now is the time to add SDK Packages by using the SDK Manager (see toolbar).
Again, I’ll refer you to the android site - Installing SDK Package because I am kind of lazy :)
Step 3: #2 Getting Started With Programming
Now the real fun (or terror, depending on who you ask) begins!
Open a new file by following the steps displayed in the images.
This is your starting point.
Still here? Great!
Step 4: #3-#7 Code and Explanation
Please see the .pdf for all the code since I cannot seem to paste it :(
But fortunately it does mean that you can easily copy the code ;)
Step 5: #8 My Final App Overview
The final outcome may look a little like the images above.
Actions to go through the images:
- Running emulator
- App with icon (AndroidProxi…)
- Default view app
- Pressed find coordinates and add alert
- Finding new coordinates after traveling
- Outside of Industrial Design
Hopefully this helps in adding your own ProximityAlerts in your apps!
These overview have been created by using the emulator and spoofing the location by adding an extra line into the Manifest.xml:
After this you go to: Tools > Android > Android Device Manager.
In the device manager you can spoof a location in the Emulator tab at Location Controls, Manual.