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

Practical 30

Uploaded by

Ansari Arman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Practical 30

Uploaded by

Ansari Arman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical 30

XML code android:layout_width="wrap_content"


<?xml version="1.0" encoding="utf-8"?> android:layout_height="wrap_content"
<LinearLayout android:hint="enter subject"
xmlns:android="http://schemas.android.com/apk/r android:textColorHint="#959595"
es/android" android:textSize="20sp"
android:layout_marginLeft="10dp"
xmlns:app="http://schemas.android.com/apk/res- android:layout_marginTop="30dp"/>
auto"
xmlns:tools="http://schemas.android.com/tools" <TextView
android:id="@+id/main" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent" android:text="Body:"
android:orientation="vertical" android:textSize="20sp"
tools:context=".MainActivity"> android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"/>
<TextView
android:layout_width="wrap_content" <EditText
android:layout_height="wrap_content" android:id="@+id/e3"
android:text="Email sender" android:layout_width="wrap_content"
android:textSize="30sp" android:layout_height="wrap_content"
android:layout_gravity="center"/> android:hint="enter body"
android:textColorHint="#959595"
<TextView android:textSize="20sp"
android:layout_width="wrap_content" android:layout_marginLeft="10dp"
android:layout_height="wrap_content" android:layout_marginTop="30dp"/>
android:text="To:"
android:textSize="20sp" <Button
android:layout_marginLeft="10dp" android:id="@+id/b1"
android:layout_marginTop="30dp"/> android:layout_width="wrap_content"
android:layout_height="wrap_content"
<EditText android:text="Submit"
android:id="@+id/e1" android:textSize="30sp"
android:layout_width="wrap_content" android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_marginTop="40dp"/>
android:hint="receiver's email"
android:textColorHint="#959595" </LinearLayout>
android:textSize="20sp"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"/> Java code
package com.example.myapplication;
<TextView
android:layout_width="wrap_content" import android.content.Intent;
android:layout_height="wrap_content" import android.os.Bundle;
android:text="Subject:" import android.view.View;
android:textSize="20sp" import android.widget.Button;
android:layout_marginLeft="10dp" import android.widget.EditText;
android:layout_marginTop="30dp"/>
import androidx.activity.EdgeToEdge;
<EditText import
android:id="@+id/e2" androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets; @Override
import androidx.core.view.ViewCompat; public void onClick(View view) {
import androidx.core.view.WindowInsetsCompat; String to = ex1.getText().toString();
String sub = ex2.getText().toString();
public class MainActivity extends String mes = ex3.getText().toString();
AppCompatActivity {
Intent email = new
EditText ex1,ex2,ex3; Intent(Intent.ACTION_SEND);
Button bx1; email.putExtra(Intent.EXTRA_EMAIL,new
@Override String[]{to});
protected void onCreate(Bundle
savedInstanceState) { email.putExtra(Intent.EXTRA_SUBJECT,sub);
super.onCreate(savedInstanceState); email.putExtra(Intent.EXTRA_TEXT,mes);
EdgeToEdge.enable(this); email.setType("message/rfc822");
setContentView(R.layout.activity_main);
ex1= findViewById(R.id.e1); startActivity(Intent.createChooser(email,"Choose
ex2= findViewById(R.id.e2); an email client"));
ex3= findViewById(R.id.e3); }
bx1 = findViewById(R.id.b1); });
}
bx1.setOnClickListener(new }
View.OnClickListener() {

Output:

You might also like