开发者

how do i get user input from the text fields and email on android?

开发者 https://www.devze.com 2023-03-08 07:00 出处:网络
hi i would like to know how i can setup the class file to get the user input from textfields and compose an email to be sent with a button?

hi i would like to know how i can setup the class file to get the user input from textfields and compose an email to be sent with a button?

example would be layout with fields

I want to bu开发者_JAVA百科y _____ I want it to be this color ____ These are my comments ____

SEND BUTTON

and it should compose an email to specific email address with subject and add the fields on the email before sending.

hope someone would have a java code for this. thanks in advance.


Fisrt you creat your custom layout and make fields for what you want then these :

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"test@lol.com"});
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"" );
            this.startActivityt(Intent.createChooser(emailIntent, ""));


i am sure on the following hint.but try this using GMailservices to send the mail

int patternMailCount=0; StringTokenizer st=new StringTokenizer(toTextField.getText().toString(),","); while(st.hasMoreElements()){ Pattern pattern = Pattern.compile("^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,4}$"); Matcher matcher = pattern.matcher(st.nextToken().toString());

//...........

} //ur implmentation

GMailSender sender = new GMailSender("yourgmail@gmail.com","your password");

sender.sendMail(
""+((EditText)findViewById(R.id.SUBTEXTFIELD)).getText().toString(), emailID,toTextField.getText().toString());

0

精彩评论

暂无评论...
验证码 换一张
取 消