I've been trying for a long time to get an alert, like the toast, to come up after the user has clicked on send button, and the e-mail has been sent. My code seem to be correct, but the toast don't show up. I've been searching a lot to get it right, but I'm stuck. Any help would be appreciated!
Regards Anders
//My code
public class mailer extends Activity {
private Button clickBtn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
clickBtn = (Button) findViewById(R.id.button1);
//clickBtn.setText("Skicka info!");
clickBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String[] recipients = new String[]{"donald@oo.se","laura@oo.se"};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Applikationsutveckling Android");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Jag vill veta mer om utbildningen!");
emailIntent.setType("text/plain");
startActivityForResult(Intent.createChooser(emailIntent, "Skicka e-post..."),1);
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
Toast.makeText(mailer.this,
"Tack för din intresseanmälan!",
Toast.LENGTH_SHORT).show();
}
}
}
}