From b97d2099177149d986f1c8eb3a6faf342d8d74b9 Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 10 Jul 2024 16:18:38 +0200 Subject: [PATCH] Construct uri and launch google maps navigation --- .../java/com/example/busroute/PathToMaps.kt | 28 +++++++++++++++++++ app/src/main/res/layout/select_path.xml | 5 ++++ 2 files changed, 33 insertions(+) diff --git a/app/src/main/java/com/example/busroute/PathToMaps.kt b/app/src/main/java/com/example/busroute/PathToMaps.kt index 79267c9..0a61b9e 100644 --- a/app/src/main/java/com/example/busroute/PathToMaps.kt +++ b/app/src/main/java/com/example/busroute/PathToMaps.kt @@ -1,7 +1,9 @@ package com.example.busroute +import android.content.Intent import android.location.Address import android.location.Geocoder +import android.net.Uri import android.os.Bundle import android.provider.BaseColumns import android.util.Log @@ -9,10 +11,12 @@ import android.view.View import android.widget.AdapterView import android.widget.AdapterView.OnItemSelectedListener import android.widget.ArrayAdapter +import android.widget.Button import android.widget.Spinner import android.widget.TableLayout import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import com.example.busroute.DataClass.BusStop import com.example.busroute.DataClass.PathList import com.example.busroute.Database.DbHelper import com.example.busroute.Database.PathContract @@ -27,6 +31,7 @@ class PathToMaps: AppCompatActivity() { val dbHelper = DbHelper(this) val db = dbHelper.readableDatabase val geocoder = Geocoder(this, Locale.getDefault()) + val StopPoint = ArrayList() setContentView(R.layout.select_path) @@ -64,6 +69,7 @@ class PathToMaps: AppCompatActivity() { id: Long ) { stopTable.removeAllViews() + StopPoint.clear() val selectedPath = parentView!!.selectedItem if(selectedPath != null){ val cursor = db.rawQuery("SELECT * " + @@ -80,6 +86,7 @@ class PathToMaps: AppCompatActivity() { val geoResults: MutableList
? = geocoder.getFromLocation(latitude, longitude, 1) text.text = "$latitude | $longitude\r${geoResults?.get(0)?.getAddressLine(0)}\n" stopTable.addView(text) + StopPoint.add("$latitude|$longitude") } } } @@ -89,5 +96,26 @@ class PathToMaps: AppCompatActivity() { // your code here } } + + + val openMapsButton = findViewById