How to do Android development using Email Client? This article covers the implementation of the Email Client in Android development. This article covers how to use the Email Client in Android to send Email from the Android Phone.
For the proper Android development and testing, it’s advisable to install these softwares on your machine.
- Eclipse Galileo 3.4 or higher versions
- Android SDK 1.5 or higher versions
- Android Development Toolkit
How to create an android project that uses Email Client to send emails from the Android Phone.
In order to understand the implementation of the Email client in Android development, follow the below mentioned steps. The code which has the Email client implementation should be written in the main class called the ‘Activity class’.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import
android.app.Activity;
import
android.content.Context;
import
android.content.DialogInterface;
import
android.content.Intent;
import
android.os.Bundle;
import
android.view.View;
import
android.view.inputmethod.InputMethodManager;
public
void
sendEmail(View v){
// The following code is the implementation
of Email client
Intent i = new
Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_EMAIL,
address);
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "Android Email client");
i.putExtra(android.content.Intent.EXTRA_TEXT, "Android Development Tutorial to send mail
from code");
startActivityForResult((Intent.createChooser(i,"Email")),1);
}
|
Now this function should be called from a view, which has a
button. And, on click of that button, sendEmail(View v)
function should be called and the mail sent from the Android
phone.
The view has the following code.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import
android.content.Context;
import
android.view.View;
import
android.view.View.OnClickListener;
import
android.widget.Button;
public
class
Sharing_FeedbackView implements
OnClickListener{
private
Button btn_Email = null;
}
public
void
onClick(View v) {
BaseView baseview = null;
if
(v == btn_Email) {
//Calling sendEmail from the activity
class
mainActivity.sendEmail(v);
}
}
|
On click of this button “btn_Email” the Email client is called from Main Activity and the mail is sent to the recipient.
please help me to fetch gmail inbox into my android email client application using javamail and imap
Hi,
Could you please suggest an approach to fetch mails form exchange server. I am looking for my own custom email client app