Share
Explore

f24 Advanced Android Lesson Planning

Requirement 1: Create an App to Start and Stop Location Tracking.
Clicking a Button toggles the location tracking to start / stop.
Updated longitude and latitude are displayed in Text Boxes.

Peter class 1 : Tuesday November 26: Location Services
Location Services
get current location of devices using FusedLocationProvider
Track Device’s Location as it moves using FusedLocationProvider

Maps Integration
Add a map to the display at a location
Display a user location on the map (blue blinking icon)
Drop PINS
Add markers to the Map

Prompt:
Sigyn, Please create a detailed Lab Lesson Workbook covering the topics of:
Location Services
get current location of devices using FusedLocationProvider
Track Device’s Location as it moves using FusedLocationProvider

Present all working error free very simple MVP minimal viable product code and worksteps.
Deliver in the stages so students can ensure correct compilation before moving on.
Ensure that all code (Build Gradle Files Project and App, MainActivity.kt, Activity_Main.xml, and AndroidManifest.xml
The build gradle files you present must work with the standard starter project I am getting from the standard Empty Views Activity Starter Template.
// build.gradle.kts project level
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
}

// build.gradle.kts app level
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
}

android {
namespace = "com.example.locationservicesnov24"
compileSdk = 34

defaultConfig {
applicationId = "com.example.locationservicesnov24"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}

Do we need to do anything with the default libs.versions.toml
[versions]
agp = "8.7.2"
kotlin = "1.9.24"
coreKtx = "1.15.0"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
appcompat = "1.7.0"
material = "1.12.0"
activity = "1.9.3"
constraintlayout = "2.2.0"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }


For stage 1: Show me the most basic setup which we can compile verify and then move on.


image.png

@done Send out a preview video teaching students how to set the current location in their emulator.
On some emulators you have to:
- open the built in Google Maps app
- click on the "center on current location button" - exit the Google maps app
- open emulator settings (location)
- push the set location button
done: Send out a pre-class video before class to demonstrate on your own computer/emulator as this is the #1 issue I've had students asked me about on previous semesters
@done: Send out a video checklist displaying examples of:
How to start and stop tracking location changes?
For example: app loads and the initial location is detected.
Some time passes and the user's location updates. The app automatically detects the change and does something with the new location (example: output to the screen).
User can push a button to tell the app to stop auto-detecting location changes .

How programmatically update the map to center on the user's location? Examples include:
User enters a lat, long into text boxes and pressed button.
When button pressed, map updates to be centered on the specified lat/lng
Lab 3: How to programmatically add a marker to the map and add an annotation to that marker?
→ user enters lat, long into text boxes and pressed button.
When button pressed, marker put on location specified.
User enters a new lat lng and marker is added to the map (so there are 2 markers in total)
Lab 4: How to obtain the location from the device and center the map on that location
- user pushes a button to get their current location
- device retrieves location
- after retrieving location, map moves be centered on their location?

Requirements: ( Map to labs by the same number)

Prompt: We are now going to write a Lab Instruction Work book to deliver these requiremennts.
We are going to build on top of the App Built in the Lab 1: Location tracking so all the foundational elements of the app are in app. The Code you write must work with the precedent
MainActivity.kt
activity_main.xml
In all cases: Respect and follow Android Application Development Best Practices.
use View Bindings as View Bindings are the new best practice in Android Kotlin Application Development. Do not in any case use findViewByID which is old and deprecated.
use set onClick Listeners Function in KOTLIN, which is the new best practice in Android Kotlin Application Development. DO NOT use Button Click Handling since Button Click Handling is old and deprecated.


### Double check that there are no references to findViewById. Use View Bindings as View Bindings are the new best practice in Android Kotlin Application Development. Do not in any case use findViewByID which is old and deprecated.
Use set onClick Listeners Function in KOTLIN, which is the new best practice in Android Kotlin Application Development. DO NOT use Button Click Handling since Button Click Handling is old and deprecated.
Requirement 1: CLICK a BUTTON to programmatically center the Map on LONG and LAT specified in TEXT BOXES.

Requirement 2: Add Markers to the map when user enters LONG and LAT in TEXT BOXES and clicks a Button. Add Annotations to Markers. For example: Royal Ontario Museum. The markers accummulate - markers previous there must remain there.

Requirement 3: Tap the Map to Drop a Marker. Provide a facility to add annotations to the markers which include longitude and lattitude. The markers are cumulative. What was there before, stays there.
Upgrade for phase 2: Add a button to clear all markers.





Here is a video I made a few terms ago:


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.