简体   繁体   中英

How to make email address variable in Android Studio

I'm sending an email in background with a fixed gmail email address (public static final String EMAIL = "abc@gmail.com" and a fixed password (public static final String PASSWORD = "abcd". Now I want to change that. The user should be able to change the email address and send the email with his personal one.

Unfortunately I wasn't that successful in reseach.

Any help is appreciated!

Thanks in advance!

I didn't understand what you mean by Email eligible.

If you mean eligible(valid) Email address then use this method

private boolean isValidEmaillId(String email){

    return Pattern.compile("^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
            + "((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
            + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
            + "([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
            + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
            + "([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$").matcher(email).matches();
}

i didn't get your question. maybe this will help.

In Android, non-static final variables can be assigned a value either in constructor or with the declaration. But, static final variables cannot be assigned value in constructor; they must be assigned a value with their declaration.

For Checking Email Address pattern

public final static boolean isValidEmail(CharSequence myEmail) {
  return !TextUtils.isEmpty(myEmail) && android.util.Patterns.EMAIL_ADDRESS.matcher(myEmail).matches();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM