2

Hello Friends i wan to make editable false in all edittext when i send mail by my application
programmatically

Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto","test@mymail.com, null));

emailIntent.putExtra(Intent.EXTRA_SUBJECT, "My Subject");

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Message);
startActivity(Intent.createChooser(emailIntent, "Send email..."));
finish();

friends my question is i want Text Subject Feild and Text/Body feild Read Only user can not edited it's value so how can i make it any idae?

kamwo
  • 1,980
  • 1
  • 23
  • 32
Harshal Kalavadiya
  • 2,412
  • 4
  • 38
  • 71

3 Answers3

0

your passing a intent to android device to handle mailing function specifying to handle it once intent is passed it will be handle by gmail or any other email client installed in your phone once they handle and get your data that is subject and message your application will be in paused state i mean to say you don't have control over other applications that handles your data.

create your mail handling and sending mail instead of passing it as intent

set editable false works only when you have those edit fields inside your application not in other activities that are started by your intent

farooq shaik
  • 69
  • 1
  • 11
0

You can create you own email sending activity without passing intent to any native email client app.There you can easily disable the editText for message and subject. The code for sending email is:

public class SendMail{

    public static void main(String[] args) {

        final String username = "username@gmail.com";
        final String password = "password";

        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "587");

        Session session = Session.getInstance(props,
          new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
          });

        try {

            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("from-email@gmail.com"));
            message.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse("to-email@gmail.com"));
            message.setSubject("Testing Subject");
            message.setText("Dear Mail Crawler,"
                + "\n\n No spam to my email, please!");

            Transport.send(message);

            System.out.println("Done");

        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }
}

taken from here

Vikram Singh
  • 1,420
  • 14
  • 19
0

Basically if you choose email chooser of android to send an email you lost all the control over this intent. So overriding these behaviour is very hard and might be not possible. So overcoming on this issue you can follow this link Sending Email in Android using JavaMail API without using the default/built-in app.

You can find how to use the javamail Api as in the above link.

Now you can make your own layout for mail activity. And you can use

youreditetxtWhichyouwanttodisable.setEditable(false);

This might be useful.

Community
  • 1
  • 1