Tutorial 10 - AndroidWhere
Tutorial 10 - AndroidWhere
Tutorial 10 Sensors
MIT AI2: Android, where is my car?
(Location sensor, Map, and Pedometer)
• Note: when you test this app, it is best that you install your app onto your physical
Android device, make sure the GPS is turned on, and then walk outside to 2 different
locations.
• Or
• you can use the given template “T10_AI2_And_Where_Template.aia”, it has 2 pink
color buttons that can help you to set up 2 different locations.
1|Page
IS2023 Mobile Application for Business
Interface
2|Page
IS2023 Mobile Application for Business
• Set the Text property for the labels with fixed text as specified in the above Table.
• Uncheck the Enabled property of the RememberButton and DirectionsButton.
• Check the Screen1.Scrollable property, so that the WebViewer will fit on the screen.
This is the
original
design.
3|Page
IS2023 Mobile Application for Business
*****************************************************
Test your app Stage 1:
➢ Android device: If you use an Android device when you run the app, you
should see some GPS data appear. If you don’t get a reading, check your
Android settings for Location & Security and try going outside. You will
4|Page
IS2023 Mobile Application for Business
have to walk out of the room to see if there’s any change with your GPS
reading.
***********************************************************
*******************************************************************
Test your app Stage 2:
When the user (both Android and Emulator) clicks the
RememberButton, the current readings for the location sensor are
copied into the “remembered”labels.
********************************************************************
5|Page
IS2023 Mobile Application for Business
Activity 2. Store the car location permanently on the user’s mobile device by using TinyDB.
Step 2: Add behaviors when a user opens the app, the remembered information will be
retrieved:
6|Page
IS2023 Mobile Application for Business
*******************************************************************
Test your app Stage 4:
7|Page
IS2023 Mobile Application for Business
Activity 3. You may use the Maps and Navigation components to replace the use of
WebViewer.
8|Page
IS2023 Mobile Application for Business
For the use of the Navigation component, you must apply for your API Key:
http://ai2.appinventor.mit.edu/reference/components/maps.html#Navigation
https://openrouteservice.org/
For your testing, you may use my API key for your exercise.
API key: 5b3ce3597851110001cf6248731df57a8db547efa1f36b3d0156febd
ButtonMapAPI.Click
It will zoom the map to the user’s
current location.
It will then set the start location and
the end location for the Navigation
component, and call the
Navigation.RequestDirections to
show a route.
9|Page
IS2023 Mobile Application for Business
We add a LineString on the map so that we can show a route to guide the user.
Don’t worry about the values in PointsFromString, we will deal with it in the block editor.
10 | P a g
IS2023 Mobile Application for Business
11 | P a g
IS2023 Mobile Application for Business
1. Take screenshots of your component view and block view for all the screens
in your app.
2. Submit the screenshots to the designated Canvas "Tutorial 10 Submission
Link".
3. Make sure to include your student ID and full name on the design view's
screenshot.
4. The deadline for submission is within one week.
12 | P a g
IS2023 Mobile Application for Business
The following is the overall view of the blocks. Please read the book chapter7 for more detailed
explanations.
13 | P a g
IS2023 Mobile Application for Business
14 | P a g
IS2023 Mobile Application for Business
Done!
o Reference:
http://www.ai2.appinventor.org/bookChapters/ch
apter7.pdf
15 | P a g