Description:
Create an app that shows how to navigate by car from yourcurrent location to Montclair State University. Your app shouldstart by explaining what it does. Once a user clicks on a buttoncalled ‘Drive to MSU’, you should launch Google Maps and show theroute. (Write code in the Android Studio)
Solution
<!—activity_main.xml –>
<?xml version=”1.0″encoding=”utf-8″?>
<RelativeLayoutxmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:app=”http://schemas.android.com/apk/res-auto”
xmlns:tools=”http://schemas.android.com/tools”
android_layout_width=”match_parent”
android_layout_height=”match_parent”
tools:context=”simpleapps.my.drivetomsu.MainActivity”>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android_text=”This appshows you how to navigate by car from your current location toMontclair State University. “
android:textSize=”20sp”
android:layout_margin=”20dp”
android:textColor=”#000000″/>
<Button
android:id=”@+id/navigateBtn”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_centerInParent=”true”
android_text=”Drive toMSU”/>
</RelativeLayout>
<!—end of activity_main.xml –>
// MAinActivity.javapackage simpleapps.my.drivetomsu;import android.content.Intent;import android.net.Uri;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.Button;public class MainActivity extends AppCompatActivity implements View.OnClickListener { private Button navigateBtn;