![Send email using Intent.ACTION_SEND Send email using Intent.ACTION_SEND](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_pekU3IYy0QQK64uly95GqUkHjGqgfHdX-I-T1z_RBaTrhpPOfKtbqXZqxojNcTMks5bgB9VLNvvBCXMYzzs2LRqPXYGNmLhG2i1ZZ3AqJVibOQ0fV0hEhgvbPDhr7eES6ylB6yMGw2ph/s400/AndroidEMail_01.png)
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter email address:"
/>
android:id="@+id/email_address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter email Subject:"
/>
android:id="@+id/email_subject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailSubject"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter Text:"
/>
android:id="@+id/email_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
android:id="@+id/sendemail_intent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" Send email using Intent.ACTION_SEND "
/>
package com.exercise.AndroidEMail;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class AndroidEMail extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText edittextEmailAddress = (EditText)findViewById(R.id.email_address);
final EditText edittextEmailSubject = (EditText)findViewById(R.id.email_subject);
final EditText edittextEmailText = (EditText)findViewById(R.id.email_text);
Button buttonSendEmail_intent = (Button)findViewById(R.id.sendemail_intent);
buttonSendEmail_intent.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String emailAddress = edittextEmailAddress.getText().toString();
String emailSubject = edittextEmailSubject.getText().toString();
String emailText = edittextEmailText.getText().toString();
String emailAddressList[] = {emailAddress};
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, emailAddressList);
intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
intent.putExtra(Intent.EXTRA_TEXT, emailText);
startActivity(Intent.createChooser(intent, "Choice App t send email:"));
}});
}
}
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp-WVdVRNoSSItrVOTvl2X9CE0zg_poZkG2QR80L1lOV_t9fi4v9to6WR4WzEi5c3VfhqlH-gQHma-08CHP-Fl3WF3LkFYYfR_d_bIyKuI_wKRIX6jR6qiRpd986VnCkTyUwPToGeHyad9/s200/icons_download.gif)
Related article:
- No applications can perform this action - Check Instent available and force to install
- Send email with Image by starting activity using Intent of ACTION_SEND
0 تعليقات