IWP Assignment No. 4
IWP Assignment No. 4
4
Title:Sensors for building smart applications. Use any sensors on the device to
add rich location and motion capabilities to your app from GPS or network
location to accelerometer, gyroscope, temperature, barometer and more
Roll No.: 25
Program:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.assignmentno4">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AssignmentNo4">
<!--
TODO: Before you run your application, you need a Google Maps API key.
https://developers.google.com/maps/documentation/android-sdk/get-api-key
Once you have your API key (it starts with "AIza"), define a new property in your
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCZMGkOgjAjaVrLfykdWg2Lp2HEqHyNv98" />
<activity
android:name=".MapsActivity"
android:exported="true"
android:label="@string/title_activity_maps">
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
MapsActivity.java
package com.example.assignmentno4;
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.example.assignmentno4.databinding.ActivityMapsBinding;
super.onCreate(savedInstanceState);
binding = ActivityMapsBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
/**
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
*/
@Override
mMap = googleMap;