sending my current location as an SMS or as a link that opens google maps

2,890 views
Skip to first unread message

Cory Pickett

unread,
Feb 23, 2016, 11:04:26 PM2/23/16
to MIT App Inventor Forum
Can anyone give me some help with or point me in the direction of a tutorial that will help me with sending my current location as an SMS message. Either that or I'd like to send a link that will open google maps with my location to users. I tried just using a text message that is set to display current address, but the message sent and said "no address available." I need a starting point at least. I know GPS can be a pain, and I'm having trouble determining where to look for a guide or tutorial or anything

SteveJG

unread,
Feb 24, 2016, 8:29:35 AM2/24/16
to mitappinv...@googlegroups.com
What you want to do is not difficult; provided you have done some homework.  What tutorials have you done Cory?

Start here   Exploring with Location Sensor in AI2                   

and proceed to the tutorials here     https://appinventorforfun.wordpress.com/tag/mapping/  .  There are a lot of tutorials there regarding using the GPS and mapping at that site.  I suggest you first do the Location Sensor tutorial;
then this one (to make sure your GPS is actually working)  on your device:

Where Am I? … a very simple LocationSensor Tutorial     

                                          and then do one of the tutorials that shows how to produce a Google Static Map.

If you had done these tutorials, you would understand the message   No Address Available   means exactly that and occurs for a variety of reasons.

GPS is not difficult to program, it is difficult to understand how it works, why it occasionally does not work and how you can use the LocationSensor to effectively work with GPS in an App Inventor Project.  The MIT Location Sensor unfortunately does not have all the bells and whistles that the tool boxes have on the Java Android compilers that allow you to access NEMA strings and have total control but it does provide the basics..

When you are comfortable, create some blocks and if you still have issues, show us an image of the blocks you tried.

Be aware, sending an sms message with AI is currently limited to about 170 characters, including spaces and a developer can easily exceed that when grabbing geocoordinates and map bounds and posting it as an sms so you may have to parse your raw gps data and message prior to sending the sms to keep the message within the sms limitation. 

Regards,
Steve

Cory Pickett

unread,
Feb 28, 2016, 11:09:37 PM2/28/16
to MIT App Inventor Forum
Thanks for the reply Steve, I've done the tutorials you mentioned and tried to use what I learned in my own app, but still no luck. It;s just sending a message that says no location available. It seems like it's trying to work but sending a text message before the app establishes a location. Here are the blocks I'm using. The app is basically one I want to put on my kid's phone so if he were ever in a dangerous situation he can click a button that will text me saying hes safe or unsafe and also send his location.
block.PNG

Cory Pickett

unread,
Feb 28, 2016, 11:25:04 PM2/28/16
to MIT App Inventor Forum
Also another update...After opening my app and letting it sit for a minute or 2 then clicking my location button, it sent the location. So I think i'm correct in saying the app is trying to send a location before one is established. Is there anyway I can speed up the phone determining it's location?

JimP

unread,
Feb 29, 2016, 5:32:02 AM2/29/16
to MIT App Inventor Forum
Hi Cory,

I'm not aware of a method to speed up satellite acquisition [apart from giving your phone the clearest possible view of the sky, etc] but maybe you could use the 'Accuracy' block?

This given a numeric reading [lower the better] so perhaps you could await a suitable figure before commencing?

Jim

Auto Generated Inline Image 1

SteveJG

unread,
Feb 29, 2016, 7:55:33 AM2/29/16
to mitappinv...@googlegroups.com
You should be able 'fix' this behaviour by checking to see if the GPS has found a valid satellite fix.    Post the location reported by the LocationSensor first to a variable or a label.  When the label shows the location (and it is not No Address Available, then use a button to send the sms.    You can also inhibit the sms  by not allowing the message to be sent if the address is 'No address available"  or whatever the exact wording is (yes, you need the exact wording). You can check for this as stated in the MIT LS documentation:  :Location information might not be immediately available when an app starts. You'll have to wait a short time for a location provider to be found and used, or wait for the OnLocationChanged event

The OnLocationChanged event could be the best block to place the code that will actually send the text.  I would use an   if..then else statement.  Or you could, more awkwardly use a Clock object to poll the geocoordinate (not as nice coding).


Jim's suggestion might work too. I do not know.   A problem with using Accuracy is that within a building, this value is usually going to be a large value even though what will be reported by the LS will be close enough for your app/s purposes

In my personal apps, I used to check if the latitude or longitude is 0.  If the GPS does not have an initial fix, the LocationSensor defaulted to a 0 latitude; 0 longitude.   If both are 0, then no fix and no address will be available.  When that happens, I post a please wait for the satellite fix before proceeding. Practically, if either lat or long is exactly 0, there is no fix.    I think MIT very recently modified the code  to elicit the No Address  when there is no satellite fix (0,0 coordinates); but do not know for sure..I'll have to look.

Try some blocks with a simple case...your app that checks a phone list is pretty complicated with several Clocks that could interfere with the OnLocationChanged event.  I would  get the simple sms working with the GPS on a simple version of your app, then port the blocks to your current project.

Also, be aware, there are several similar Projects in the MIT Gallery.   You might visit it and see how other developers solved that issue (or avoided it).

Regards,
Steve

Reply all
Reply to author
Forward
0 new messages