Intent.EXTRA_EMAIL이받는 사람 필드를 채우지 않습니다.
내 애플리케이션에서 이메일을 보내기 위해 인 텐트 를 사용하려고하는데 이메일의받는 사람 필드가 채워지지 않습니다. 제목이나 텍스트를 채우는 코드를 추가하면 제대로 작동합니다. To 필드 만 채워지지 않습니다.
또한 유형을 "text / plain"및 "text / html"로 변경하려고 시도했지만 동일한 문제가 발생합니다. 누구든지 제발 도와 줄 수 있습니까?
public void Email(){
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("message/rfc822"); //set the email recipient
String recipient = getString(R.string.IntegralEmailAddress);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL , recipient);
//let the user choose what email client to use
startActivity(Intent.createChooser(emailIntent, "Send mail using...")); }
사용하려는 이메일 클라이언트는 Gmail입니다.
나는 당신이 통과되지 않은 생각 recipient
으로array of string
그것은 같아야한다
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "someone@gmail.com" });
이것을 사용하십시오
public void Email(){
// use this to declare your 'recipient' string and get your email recipient from your string xml file
Resources res = getResources();
String recipient = getString(R.string.IntegralEmailAddress);
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("message/rfc822"); //set the email recipient
emailIntent.putExtra(Intent.EXTRA_EMAIL, recipient);
//let the user choose what email client to use
startActivity(Intent.createChooser(emailIntent, "Send mail using..."));
``}
이것은 작동 할 것입니다. :)
이것은 Intent.Extra_Email-
모든 "받는 사람"수신자 이메일 주소의 문자열 배열에 대해 안드로이드 문서에서 말하는 것 입니다.
따라서 문자열을 올바르게 공급해야합니다. 자세한 내용은 여기
http://developer.android.com/guide/components/intents-common.html#Email 및 여기 http://developer.android.com/guide/topics/resources 에서 읽을 수 있습니다. /string-resource.html 또는 ACTION_SENDTO 작업을 사용하고 "mailto :"데이터 스키마를 포함합니다. 예를 들면 :
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
private void callSendMeMail() {
Intent Email = new Intent(Intent.ACTION_SEND);
Email.setType("text/email");
Email.putExtra(Intent.EXTRA_EMAIL, new String[] { "me@gmail.com" });
Email.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
startActivity(Intent.createChooser(Email, "Send mail to Developer:"));
}
몇 가지 :
1-액션 상수 변수를 ACTION_SENDTO로 설정해야합니다. Intent intentEmail = new Intent(Intent.ACTION_SENDTO);
2-메일로만 열려면 setData () 메서드를 사용합니다. intentEmail.setData(Uri.parse("mailto:"));
그렇지 않으면 장치에있는 다른 앱에서 텍스트, 이미지, 오디오 파일로 열도록 요청합니다.
3-이메일 ID 문자열을 문자열이 아닌 배열 객체 로 전달해야 합니다. 문자열은 "name@email.com" 입니다. 문자열의 배열 객체는 new String [] { "email1", "email2", "more_email"} 입니다.
intentEmail.putExtra(Intent.EXTRA_EMAIL, new String[] {"email@overflow.com", "abcd@stack.com"});
참고 URL : https://stackoverflow.com/questions/9097080/intent-extra-email-not-populating-the-to-field
'developer tip' 카테고리의 다른 글
XSD 파일의 목적은 무엇입니까? (0) | 2020.09.11 |
---|---|
Ruby on Rails Database.yml 파일의 MySQL 구성 수정 (0) | 2020.09.11 |
Twitter Bootstrap을 사용하여 테이블 셀에서 세로로 버튼 중앙에 배치 (0) | 2020.09.11 |
CONDITIONS가있는 COUNT DISTINCT (0) | 2020.09.11 |
jQuery는 AJAX 쿼리에서 내 JSON을 구문 분석하지 않습니다. (0) | 2020.09.11 |