Get current location with latitude and longtitude using kotlin
<ol>
<li>This tutorial about get current location with latitude and longtitude using kotlin.</li>
</ol>
<p>2. Add permission in manifest</p>
<pre>
<<strong>uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" </strong>/>
<<strong>uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" </strong>/></pre>
<p>3. xml layout</p>
<pre>
<em><?</em><strong>xml version="1.0" encoding="utf-8"</strong><em>?>
</em><<strong>RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
tools:context=".MainActivity"</strong>>
<<strong>TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:background="#008080"
android:padding="5dp"
android:text="Hello World"
android:textColor="#fff"
android:textSize="24sp"
android:textStyle="bold" </strong>/>
<<strong>TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Get GPS Location"
android:textColor="@android:color/holo_red_dark"
android:textSize="24sp"
android:textStyle="bold" </strong>/>
<<strong>Button
android:id="@+id/getLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_centerInParent="true"
android:layout_marginTop="40dp"
android:text="Get location" </strong>/>
</<strong>RelativeLayout</strong>></pre>
<p>4. kotlin code when click on button display latitude and longtitude in textview</p>
<p><a href="https://medium.com/@hasperong/get-current-location-with-latitude-and-longtitude-using-kotlin-2ef6c94c7b76">Visit Now</a></p>