PR (30,31)
PR (30,31)
PR (30,31)
android:layout_width="match_parent"
Roll No: 8
Q30)
android:layout_height="wrap_content"
Activity_main.xml:
android:layout_marginTop="8dp"
<?xml version="1.0" encoding="utf-8"?>
android:hint="Subject" />
<LinearLayout
xmlns:android="http://schemas.android.c
om/apk/res/android" <EditText
android:layout_width="match_parent" android:id="@+id/editTextBody"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="16dp">
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
<EditText
android:hint="Body"
android:id="@+id/editTextSender"
android:minLines="4"
android:inputType="textMultiLine" />
android:layout_width="match_parent"
android:layout_height="wrap_content" <Button
android:hint="Your Email Address" /> android:id="@+id/buttonSend"
android:layout_width="wrap_content"
<EditText
android:id="@+id/editTextRecipient"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center_horizontal
"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="Recipient Email" />
android:text="Send" />
<EditText
</LinearLayout>
android:id="@+id/editTextSubject"
Name: Aditya Kumar Sah import androidx.core.app.ActivityCompat;
Q31)
Activity_main.xml: import org.osmdroid.api.IMapController;
<RelativeLayout import
xmlns:android="http://schemas.android.com/ org.osmdroid.tileprovider.tilesource.TileSource
apk/res/android" Factory;
import org.osmdroid.util.BoundingBox;
xmlns:tools="http://schemas.android.com/too import org.osmdroid.util.GeoPoint;
ls"
import org.osmdroid.views.MapView;
android:layout_width="match_parent"
import
android:layout_height="match_parent" org.osmdroid.views.overlay.mylocation.GpsMy
tools:context=".MainActivity"> LocationProvider;
import
org.osmdroid.views.overlay.mylocation.MyLoc
<org.osmdroid.views.MapView ationNewOverlay;
android:id="@+id/mapView"
import android.Manifest;
@Override
import android.content.pm.PackageManager;
protected void onCreate(Bundle
import android.os.Bundle; savedInstanceState) {
setContentView(R.layout.activity_main);
import androidx.annotation.NonNull;
Q30) android:layout_height="wrap_content"
Activity_main.xml: android:layout_marginTop="8dp"
<?xml version="1.0" encoding="utf-8"?> android:hint="Subject" />
<LinearLayout
xmlns:android="http://schemas.android.c
om/apk/res/android" <EditText
android:layout_width="match_parent" android:id="@+id/editTextBody"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="16dp"> android:layout_height="wrap_content"
android:layout_marginTop="8dp"
<EditText android:hint="Body"
android:id="@+id/editTextSender" android:minLines="4"
android:inputType="textMultiLine" />
android:layout_width="match_parent"
android:layout_height="wrap_content" <Button
android:layout_width="wrap_content"
<EditText
android:id="@+id/editTextRecipient" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_gravity="center_horizontal
"
android:layout_height="wrap_content" android:layout_marginTop="16dp"
android:hint="Recipient Email" /> android:text="Send" />
<EditText </LinearLayout>
android:id="@+id/editTextSubject"
Name: Prathambhoir import androidx.core.app.ActivityCompat;
Q31)
import org.osmdroid.api.IMapController;
Activity_main.xml:
import org.osmdroid.config.Configuration;
<?xml version="1.0" encoding="utf-8"?>
import
<RelativeLayout
org.osmdroid.tileprovider.tilesource.TileSource
xmlns:android="http://schemas.android.com/
Factory;
apk/res/android"
import org.osmdroid.util.BoundingBox;
xmlns:tools="http://schemas.android.com/too import org.osmdroid.util.GeoPoint;
ls"
import org.osmdroid.views.MapView;
android:layout_width="match_parent"
import
android:layout_height="match_parent" org.osmdroid.views.overlay.mylocation.GpsMy
LocationProvider;
tools:context=".MainActivity">
import
org.osmdroid.views.overlay.mylocation.MyLoc
<org.osmdroid.views.MapView ationNewOverlay;
android:id="@+id/mapView"
import android.Manifest;
@Override
import android.content.pm.PackageManager;
protected void onCreate(Bundle
import android.os.Bundle; savedInstanceState) {
setContentView(R.layout.activity_main);
import androidx.annotation.NonNull;
android:layout_height="wrap_content" <Button
android:hint="Your Email Address" /> android:id="@+id/buttonSend"
android:layout_width="wrap_content"
<EditText
android:id="@+id/editTextRecipient"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center_horizontal
"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="Recipient Email" />
android:text="Send" />
<EditText
</LinearLayout>
android:id="@+id/editTextSubject"
MainActivity.java: editTextRecipient =
findViewById(R.id.editTextRecipient);
package com.example.practicaal;
editTextSubject =
findViewById(R.id.editTextSubject);
import android.content.Intent;
editTextBody =
import android.net.Uri; findViewById(R.id.editTextBody);
EditText editTextSender,
private void sendEmail() {
editTextRecipient, editTextSubject,
editTextBody; String senderEmail =
editTextSender.getText().toString().trim();
Button buttonSend;
String recipientEmail =
editTextRecipient.getText().toString().trim(
@Override );
setContentView(R.layout.activity_main);
Intent intent = new
Intent(Intent.ACTION_SEND);
editTextSender =
findViewById(R.id.editTextSender); intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL,
new String[]{recipientEmail});
intent.putExtra(Intent.EXTRA_SUBJECT,
subject);
intent.putExtra(Intent.EXTRA_TEXT,
body);
if
(intent.resolveActivity(getPackageManage
r()) != null) {
startActivity(Intent.createChooser(intent,
"Send Email"));
} else {
Toast.makeText(MainActivity.this,
"No email app found",
Toast.LENGTH_SHORT).show();
}
}
Output:
Name: Jignesh Kanoujia import androidx.core.app.ActivityCompat;
Q31)
Activity_main.xml: import org.osmdroid.api.IMapController;
<RelativeLayout import
xmlns:android="http://schemas.android.com/ org.osmdroid.tileprovider.tilesource.TileSource
apk/res/android" Factory;
import org.osmdroid.util.BoundingBox;
xmlns:tools="http://schemas.android.com/too import org.osmdroid.util.GeoPoint;
ls"
import org.osmdroid.views.MapView;
android:layout_width="match_parent"
import
android:layout_height="match_parent" org.osmdroid.views.overlay.mylocation.GpsMy
tools:context=".MainActivity"> LocationProvider;
import
org.osmdroid.views.overlay.mylocation.MyLoc
<org.osmdroid.views.MapView ationNewOverlay;
android:id="@+id/mapView"
import android.Manifest;
@Override
import android.content.pm.PackageManager;
protected void onCreate(Bundle
import android.os.Bundle; savedInstanceState) {
setContentView(R.layout.activity_main);
import androidx.annotation.NonNull;
mapView.setMaxZoomLevel(20.0);
if
(ContextCompat.checkSelfPermission(this, mapView.setHorizontalMapRepetitionEnabled
Manifest.permission.ACCESS_FINE_LOCATION) (false);
!=
PackageManager.PERMISSION_GRANTED) { mapView.setVerticalMapRepetitionEnabled(fal
se);
// Permission is not granted, request it
mapView.setScrollableAreaLimitLatitude(map
ActivityCompat.requestPermissions(this,
View.getTileSystem().getMaxLatitude(),
new mapView.getTileSystem().getMinLatitude(), 0);
String[]{Manifest.permission.ACCESS_FINE_LO
CATION},
// Add a marker for user's location
setupMap(); mapView.getOverlays().add(myLocationOverla
y);
}
myLocationOverlay.enableMyLocation();
}
if (startPoint != null) {
mapView.setTileSource(TileSourceFactory.MA IMapController mapController =
PNIK); mapView.getController();
mapView.setMultiTouchControls(true); mapController.setCenter(startPoint);
super.onResume();
mapView.getController().setCenter(defaultLoc mapView.onResume();
ation);
}
mapView.getController().setZoom(5); //
Set a default zoom level
} @Override
} super.onPause();
mapView.onPause();
@Override }
super.onRequestPermissionsResult(requestCo }
de, permissions, grantResults);
android { }
namespace = "com.example.practicaal"
compileSdk = 34 dependencies {
defaultConfig {
implementation("androidx.appcompat:appco
applicationId = "com.example.practicaal"
mpat:1.6.1")
minSdk = 24
targetSdk = 34 implementation("com.google.android.materia
l:material:1.11.0")
versionCode = 1
testInstrumentationRunner =
"androidx.test.runner.AndroidJUnitRunner" implementation("androidx.navigation:navigati
on-fragment:2.7.7")
}
implementation("androidx.navigation:navigati
buildTypes { on-ui:2.7.7")
release { implementation("org.osmdroid:osmdroid-
android:6.1.10")
isMinifyEnabled = false
implementation("org.osmdroid:osmdroid-
mapsforge:6.1.10")
proguardFiles(getDefaultProguardFile("progua
rd-android-optimize.txt"), "proguard-
rules.pro") implementation("com.google.android.gms:pla
y-services-maps:18.2.0")
}
} implementation("com.google.android.gms:pla
y-services-location:21.2.0")
compileOptions {
testImplementation("junit:junit:4.13.2")
sourceCompatibility =
JavaVersion.VERSION_1_8
androidTestImplementation("androidx.test.ext
targetCompatibility =
:junit:1.1.5")
JavaVersion.VERSION_1_8
}
androidTestImplementation("androidx.test.es
buildFeatures { presso:espresso-core:3.5.1")
viewBinding = true
}
}
android:theme="@style/Theme.Practicaal"
AndroidManifest.xml:
tools:targetApi="31">
<?xml version="1.0" encoding="utf-8"?>
<activity
<manifest
xmlns:android="http://schemas.android.com/ android:name=".MainActivity2"
apk/res/android"
android:exported="false"
xmlns:tools="http://schemas.android.com/too
android:label="@string/title_activity_main2"
ls">
<uses-permission
android:theme="@style/Theme.Practicaal" />
android:name="android.permission.ACCESS_F
INE_LOCATION" /> <activity
<uses-permission android:name=".MainActivity"
android:name="android.permission.ACCESS_C
android:exported="true"
OARSE_LOCATION" />
android:label="@string/app_name"
<uses-permission
android:name="android.permission.WRITE_EX
TERNAL_STORAGE"/> android:theme="@style/Theme.Practicaal">
<uses-permission <intent-filter>
android:name="android.permission.INTERNET
" /> <action
android:name="android.intent.action.MAIN"
<uses-feature />
android:name="android.hardware.location.gp
s" />
<application <category
android:name="android.intent.category.LAUN
android:allowBackup="true" CHER" />
</intent-filter>
android:dataExtractionRules="@xml/data_ext
raction_rules" </activity>
<receiver android:name=".Broad"
android:fullBackupContent="@xml/backup_ru android:exported="true">
les"
<intent-filter>
android:icon="@mipmap/ic_launcher"
<action
android:label="@string/app_name" android:name="android.intent.action.AIRPLA
NE_MODE"></action>
android:roundIcon="@mipmap/ic_launcher_r </intent-filter>
ound"
</receiver>
android:supportsRtl="true"
</application>
</manifest>
Output: