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

Exp 30

The document outlines the code for an Android application that allows users to send emails. It includes XML layout for the user interface with fields for 'To', 'Subject', and 'Message', as well as a button to send the email. The Java code handles the email sending functionality using an Intent and displays a Toast message upon successful sending.

Uploaded by

sawantkrish562
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)
7 views2 pages

Exp 30

The document outlines the code for an Android application that allows users to send emails. It includes XML layout for the user interface with fields for 'To', 'Subject', and 'Message', as well as a button to send the email. The Java code handles the email sending functionality using an Intent and displays a Toast message upon successful sending.

Uploaded by

sawantkrish562
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
You are on page 1/ 2

EXP 30

private EditText eTo;


<?xml version="1.0" encoding="utf-8"?> private EditText eSubject;
<LinearLayout private EditText eMsg;
xmlns:android="http://schemas.android.com/ap private Button btn;
@Override
k/res/android"
android:layout_width="match_parent" protected void onCreate(Bundle
android:layout_height="match_parent" savedInstanceState) {
android:paddingLeft="20dp" super.onCreate(savedInstanceState);
android:paddingRight="20dp" setContentView(R.layout.activity_main);
android:orientation="vertical" > eTo = (EditText)findViewById(R.id.txtTo);
<EditText eSubject =
android:id="@+id/txtTo" (EditText)findViewById(R.id.txtSub);
android:layout_width="match_parent" eMsg = (EditText)findViewById(R.id.txtMsg);
android:layout_height="wrap_content" btn = (Button)findViewById(R.id.btnSend);
android:hint="To"/> btn.setOnClickListener(new
View.OnClickListener() {
<EditText
android:id="@+id/txtSub" @Override
android:layout_width="match_parent" public void onClick(View v) {
android:layout_height="wrap_content" Intent it = new
android:hint="Subject"/> Intent(Intent.ACTION_SEND);
<EditText it.putExtra(Intent.EXTRA_EMAIL, new
android:id="@+id/txtMsg" String[]{eTo.getText().toString()});
android:layout_width="match_parent"
android:layout_height="0dp" it.putExtra(Intent.EXTRA_SUBJECT,eSubject.getTe
android:layout_weight="1" xt().toString());
android:gravity="top"
android:hint="Message"/> it.putExtra(Intent.EXTRA_TEXT,eMsg.getText());
<Button it.setType("message/rfc822");
android:layout_width="100dp"
android:layout_height="wrap_content" startActivity(Intent.createChooser(it,"Choose Mail
android:layout_gravity="right" App"));
android:text="Send"
android:id="@+id/btnSend"/> Toast.makeText(getApplicationContext(),"Email
sent to " + eTo.getText().toString() ,
</LinearLayout>
Toast.LENGTH_LONG).show();
eMsg.setText("");
eTo.setText("");
package com.example.emailsend; eSubject.setText("");
}
import });
androidx.appcompat.app.AppCompatActivity; }
}
import android.content.Intent;
import android.os.Bundle; AndroidManifest.xml
import android.view.View;
<?xml version="1.0" encoding="utf-8"?>
import android.widget.Button;
import android.widget.EditText; <manifest
import android.widget.Toast; xmlns:android="http://schemas.android.com/ap
k/res/android"
public class MainActivity extends package="com.example.emailsend">
AppCompatActivity {
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

android:roundIcon="@mipmap/ic_launcher_roun
d"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCH
ER" />
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCH
ER" />
<action
android:name="android.intent.action.SEND"/>
<category
android:name="android.intent.category.DEFAULT
"/>
<data
android:mimeType="message/rfc822"/>
</intent-filter>
</activity>
</application>
</manifest>

You might also like