MAD*_*DGE 3 android email-client form-submit
我已经使用Java和Xml工作了几个月,并且感谢StackOverflow上的每个人都提供了很多帮助.
我的问题是关于提交按钮的android的java编程.
目前我正在试图弄清楚如何将值提交到电子邮件地址(幕后)
假设我们有一个文本字段和一个按钮; 我想获取在文本字段中输入的值,并将其提交到电子邮件地址onclick.
我无法在网上找到任何显示如何执行此操作的内容.
提前感谢您阅读我的帖子,我期待着您的建议.
rob*_*y12 10
这是一个很好的例子,说明如何使用它Intents可以派上用场!Android有一堆预先定义的Intent,可以在系统中执行某些操作; 您可能之前点击了一张图片,并弹出一个对话框,询问您是要在图库中还是在Astro等第三方应用中查看.观看图像具有其自己的预定意图.
发送电子邮件也有其预先确定的意图:android.content.Intent.ACTION_SEND.您需要使用该属性创建一个intent,然后附加额外信息(即要发送到的地址,主题/消息正文等).
示例代码:
// Data members
private Intent emailIntent;
private String feedback;
private EditText feedbackBox;
// Create the Intent, and give it the pre-defined value
// that the Android machine automatically associates with
// sending an email.
emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
// Put extra information into the Intent, including the email address
// that you wish to send to, and any subject (optional, of course).
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"your_email@whatever.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Insert subject here");
// Acquire feedback from an EditText and save it to a String.
feedback = feedbackBox.getText().toString();
// Put the message into the Intent as more extra information,
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, feedback);
// Start the Intent, which will launch the user's email
// app (make sure you save any necessary information in YOUR app
// in your onPause() method, as launching the email Intent will
// pause your app). This will create what I discussed above - a
// popup box that the user can use to determine which app they would like
// to use in order to send the email.
startActivity(Intent.createChooser(emailIntent, "Insert title for dialog box."));
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助!!
您可能希望查看的一些来源:
http ://developer.android.com/guide/topics/intents/intents-filters.html
http://developer.android.com/reference/android/content/Intent.html# ACTION_SEND
| 归档时间: |
|
| 查看次数: |
5816 次 |
| 最近记录: |