Make phone sound alarm and vibrate when you get 2 meters from phone

38 views
Skip to first unread message

Stephen Mattison

unread,
Mar 9, 2019, 11:39:29 AM3/9/19
to MIT App Inventor Forum
Howdy!  LOVING MIT App Inventor, TYVM!
I want to build an app that will use NFC, or RFID, or BT to measure/know when User travels, for example, 2 meters away from phone.  When User travels farther than set distance, phone will make sounds and/or vibrate.  I want an app that will make it impossible to walk out of a room and leave my phone laying there.  Need to be able to set distance according to surroundings/danger.  If I'm at home, I would set it to 2 or 3 meters, but if I were on the Subway, I'd set it to .5 or 1 meter to be sure my phone never leaves my pocket.
I made a neat little App that uses Proximity sensor and it works great, but this will only measure in cm, uses sensors to measure how far away your face is from the screen.  I need a sensor in my pocket or wallet that will allow App/phone to measure distance I am from my phone.  TYVM!

SteveJG

unread,
Mar 9, 2019, 1:51:21 PM3/9/19
to MIT App Inventor Forum
Sorry to disappoint Stephen.  What you want to do is probably impossible with App Inventor and probably also true of any Android compiler.

You might be able to use Bluetooth if you have some kind of gadget that has a GPS receiver in it and carry it on your person so it can tell your phone where you are located and the phone can calculate how far away you might be.   However, because of a characteristic of GPS called Accuracy, a problem is that a GPS in a phone only knows at best where it is located within about 2 meters and generally it is uncertain of its precise location with far less confidence.  Unfortunately this +/- error is what you require  .. 2 meters.    Similarly, you could carry a second phone and use one of the Cloud databases to exchange positional information between the devices-it too has the same issue.  You can read about Accuracy here Using the Location Sensor

Preventing this app from working as you like your phone goes to sleep when not in use.   When your phone goes to sleep the app 'stops working' ( App Inventor cannot work as a Service..what is required for the phone to be alert in the background).  Sorry, the phone is lazy, you cannot keep it active unless you use a Stay Awake procedure (which drains the Android battery rapidly).

Neat idea.   The problem is, the phone might know where it is, but to know how far away you are, it has to know where you are.

Here are some resources to help you learn to use the AI2 tools  A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .



Regards,
Steve

TimAI2

unread,
Mar 9, 2019, 1:52:45 PM3/9/19
to MIT App Inventor Forum
And your phone will need to be awake ALL THE TIME for this to work!
Background tasks are not possible with AI2

Not sure I know of any NFC/RFID tags that will work from 2 metres away(could be wrong) and for Bluetooth you would need to be wearing a bluetooth device communicating with the phone
Reply all
Reply to author
Forward
0 new messages