Harry Mangurian

unread,
Nov 5, 2015, 9:00:22 AM11/5/15
to MIT App Inventor Forum
I wrote an app that uses location.

It is working, but I have a few questions:

  1. If multiple location sensors are available (e.g. wifi, gps, and/or cellular) are all three used or is the most accurate used?
  2. Is there a way for the app to identify which location technique is in use?
  3. If only cellular is available and the phone is on, will App Inventor automatically use cellular? ( I do not have cell on my tablet, so I can't test that)

Many Thanks,

SteveJG

unread,
Nov 5, 2015, 9:46:35 AM11/5/15
to mitappinv...@googlegroups.com
#1   Depends on how the Provider is configured.  See the LocationSensor tutorial.      All three Providers (are are not three different sensors, just diffferent Methods)  are not used simultaneously. If none are specified in code then the Android will choose.    All things being equal, the most precise is gps, followed by WIFI   then network.  network uses the cell towers, WIFI uses other info.   The AI2 LS does not have the capability to discriminate among the other options that might be available when coded using Android Studio etc.  See the LocationSensor tutorial, it explains it all Harry.  If the Provider is left unlocked, the Android is supposed to find a method that works.  If the GPS receiver is turned off on the Android using Settings, either wifi or network will be used.  Users can specify the method and lock it in so only that method works.  It is possible for providers to switch when the current provider is unable to provide adequate location fixes for circumstances. if the provider is left unlocked.  How accurate the reading one gets on the device is available using the Accuracy property ... an Accuracy 'square' is shown in this tutorial 

AI2 Static Maps 104…calculate distances between points and add an Accuracy Square

Not all devices have the ability to check for Accuracy so there is a block you can use to check for it.

#2   Not sure. Possibly.   Try the LocationSensor1.ProviderName  block in a label.   That might work if the developer does not specifically set the method and even if it is set specifically.  Try some blocks.  The AvailableProvider block shows which Providers are available on a device.   The StatusChanged block might be used to report the current ProviderName...never tried it.

#3.  If the phone is on and network is specified the phone should use cellular if the GPS receiver is turned off using Settings...I don't know for sure.  The phone might require a DATA connection plan.  Good question.  Perhaps someone will tell us?

The MIT LocationSensor tutorial answers most of these questions.  You might want to read the tutorial again  Exploring with Location Sensor in AI2
The location sensor object is used to communicate with the global positioning satellite receiver (GPS) in your phone/tablet. When the LocationSensor communicates with the built-in GPS receiver, the GPS can determine the location of your device.  The sensor can also work with network/wifi location services.  Finding a location using the network uses very different techniques to determine a location. Location means, the device's present latitude and longitude or it can mean your street address.           

and the App Inventor LocationSensor documentation   http://ai2.appinventor.mit.edu/reference/components/sensors.html#LocationSensor  (although the LS tutorial has an annotated, more robust explanation).

Let us know what you discover regarding #2 and #3 Harry    and have fun with your Project.

Regards,
Steve
Reply all
Reply to author
Forward
0 new messages