-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmailActivity.java
57 lines (45 loc) · 1.89 KB
/
EmailActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.example.asmid.pricetag;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
/**
* Created by asmid on 11/24/2016.
*/
public class EmailActivity extends Activity {
Button buttonSend;
EditText textTo;
EditText textSubject;
EditText textMessage;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_email);
buttonSend = (Button) findViewById(R.id.buttonSend);
textTo = (EditText) findViewById(R.id.editTextTo);
textSubject = (EditText) findViewById(R.id.editTextSubject);
textMessage = (EditText) findViewById(R.id.editTextMessage);
buttonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String to = textTo.getText().toString();
String subject = textSubject.getText().toString();
String message = textMessage.getText().toString();
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Selling to you");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Contact me");
emailIntent.setType("message/rfc822");
try {
startActivity(Intent.createChooser(emailIntent, "choose an email client"));
finish();
}catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(EmailActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}
});
}
}