0% found this document useful (0 votes)
81 views2 pages

Deploying Map-Based Apps in Android

The document contains a practical assignment for deploying a map-based application using XML and Java code. It includes the XML layout for a map fragment and Java code for an Android activity that retrieves and displays the user's location on the map. The code utilizes Google Maps API and location services to show the user's current position with a marker.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views2 pages

Deploying Map-Based Apps in Android

The document contains a practical assignment for deploying a map-based application using XML and Java code. It includes the XML layout for a map fragment and Java code for an Android activity that retrieves and displays the user's location on the map. The code utilizes Google Maps API and location services to show the user's current position with a marker.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: Shreyas Liladhar Lokhande Roll No: 41

Class: TYCM Batch: B

Subject: MAD
Practical No & Name: 31. Deploy map-based application. Part I

XML Code: Output:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout
xmlns:android="[Link]
android"
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<fragment
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mapFragment"
android:name="[Link]
.SupportMapFragment"
/>
</RelativeLayout>

Java Code :
package [Link].pr31;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity implements


OnMapReadyCallback {
private GoogleMap mMap;
private FusedLocationProviderClient fusedLocationClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
fusedLocationClient =
[Link](this);
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById([Link]);
if (mapFragment != null) [Link](this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap=googleMap;
showLocation();
}
@SuppressLint("MissingPermission")
private void showLocation() {
[Link]().addOnSuccessListener(this,
location -> {
if (location != null && mMap != null) {
LatLng userLocation = new LatLng([Link](),
[Link]());
[Link](new
MarkerOptions().position(userLocation).title("You are here"));

[Link]([Link](userLocation,
15));
}
});
}
}

You might also like