clicking function in android [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this questionhow to connect to email while clicking on button in android
If you want to send something by email your best bet is to use ACTION_SEND
. Then it can be picked-up by email app, Twitter app, Facebook app - depending on what apps user may have on his device
private void sendBy(final String title, final String text) {
Intent i = new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, title);
i.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(i, "Send this job by"));
}
I believe you're looking at two separate questions.
How do you link a button on the XML layout into your code. What you're wanting is an "onClickListener".
There are many tutorials and example code out on the web. http://tseng-blog.nge-web.net/blog/2009/02/14/implementing-listeners-in-your-android-java-application/
(The important thing to note is the lines 14-27 in that example. That code gets executed when that button is clicked.
Then you're wanting to do Email. There are a a few protocols you're going to need to know about. SMTP is the protocol for sending messages. POP3 and IMAP are used for getting messages.
Look up on google for Android SMTP and Android IMAP examples / tutorials.
That should get you started.
精彩评论