Using the location sensor with App Inventor Level

  • Slides: 11
Download presentation
Using the location sensor with App Inventor Level 1 Display location values, parameters &

Using the location sensor with App Inventor Level 1 Display location values, parameters & track Mobile CSP 2016 Pierre Huguet pierre. huguet 50@gmail. com

Level 1 includes – Initial setup and display of current location provider – Location

Level 1 includes – Initial setup and display of current location provider – Location display and update (on location change event) Ø availability, values and accuracy of latitude and longitude Ø availability and value of altitude Ø current and previous provider (when last location changed) Ø List of enabled location providers Ø location time – Selection of location provider in Ø high accuracy (GPS+Network) mode, Ø battery saving (Network only) mode, Ø device only (GPS only) mode. Note : when in Battery saving/network mode, check that Wifi is on (accuracy will be much better) 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

App components : level 1 number latitude longitude altitude accuracy 3 D (alt) Provider

App components : level 1 number latitude longitude altitude accuracy 3 D (alt) Provider time 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

App program blocks : level 1 (1/5) Variables : Location fix : a list

App program blocks : level 1 (1/5) Variables : Location fix : a list which holds location information (latitude, longitude, altitude, accuracy, 3 D, provider, time, …), Track : the list of Location fixes Location Fix Instant : time of last location fix At startup : Display current location provider Set values for the location sensor time and distance intervals (in milliseconds and meters). 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

App program blocks : level 1 (2/5) Location change event handler On location change

App program blocks : level 1 (2/5) Location change event handler On location change : 1 1. Update Location. Fix label 2. Fill up all values of the new location fix, 3. Add it to the track, 4. Display location info and track history. 2 3 4 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

App program blocks : level 1 (3/5) List picker handler to select and change

App program blocks : level 1 (3/5) List picker handler to select and change location provider • When clicking on the provider list picker : – Display the list of enabled providers, – Select provider, – Update location sensor provider after unlocking it (then relock it). • Note : – Locking/unlocking the provider is necessary for some devices to avoid unexepected behavior. – The list of enabled providers depends on device « location » configuration (see later slide) 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

App program blocks : level 1 (4/5) function to display track under list format

App program blocks : level 1 (4/5) function to display track under list format Set components’s visibilty to display track Write column headers : n°, latitude, longitude, … Loop on track locations to fill column values 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

App program blocks : level 1 (5/5) Function to display the location sensor information

App program blocks : level 1 (5/5) Function to display the location sensor information Set local default values if no input data Set local values if valid data • This function displays location info available in the location. Fix input parameter. • If the location. Fix input is empty, default information is displayed. Fill in labels for display 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

Level 1 : blocks overview 07/2016 Location and GPS tutorial for App Inventor, pierre.

Level 1 : blocks overview 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

Device setup – App Inventor Providers Device Setup : set Location ON Device Setup

Device setup – App Inventor Providers Device Setup : set Location ON Device Setup : Select one of three location modes Corresponding enabled providers in App Inventor (select from list picker) 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com

Practice 1. Points 1 and 2 : Starting indoors => network mode 3 D

Practice 1. Points 1 and 2 : Starting indoors => network mode 3 D is false : Altitude is not available estimated accuracy : 19 meters (GPS tested but not working) 2. Points 3 and 4 : Going outdoors (balcany 3 rd floor/11) 3 D true : altitude becomes available accuracy 28 m (not as good as network) Try : "airplane" privacy mode : What works and why ? "Network" mode with/without Wifi : What changes ? Question : Choose between privacy, availability and precision ? Warning : When switching back to network, 3 D may show as true but this is wrong : Network location is 2 D only. 07/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com