2012-01-24 2 views
2

저는 몇 달 동안 Java 및 Xml로 작업 해 왔으며 StackOverflow에 대한 모든 도움을 주신 덕분에 많은 것을 배웠습니다.Android 단추 onclick 이메일로 전송

제 질문은 제출 버튼과 관련하여 안드로이드에 대한 자바 프로그래밍에 관한 것입니다.

은 현재 내가

우리가 텍스트 필드와 버튼이 말할 수 있습니다 (뒤에서) 이메일 주소에 값을 제출하는 방법을 알아 내려고 노력하고 있어요; 텍스트 필드에 입력 한 값을 가져 와서 전자 메일 주소 onclick에 제출하고 싶습니다.

나는 이것을하는 방법을 보여주는 온라인을 찾을 수 없습니다.

내 게시물을 읽는 데 미리 감사드립니다. 귀하의 제안을 기다리겠습니다.

+0

당신이이 포스트를 보면, Gmail을 사용하려는 경우, http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-android-ap – aacanakin

답변

8

Intents을 사용하면 어떻게 편리할까요? Android에는 시스템 내에서 특정 작업을 수행하는 사전 정의 된 Intents가 있습니다. 이전에 사진을 클릭했을 수도 있고 갤러리 또는 Astro와 같은 타사 응용 프로그램에서 볼 것인지 묻는 대화 상자가 나타날 수도 있습니다. 이미지보기에는 자체 사전 결정된 의도가 있습니다.

이메일을 보내는 경우 미리 결정된 의도가 있습니다 (android.content.Intent.ACTION_SEND). 이 속성으로 인 텐트를 만든 다음 추가 정보 (예 : 보낼 주소, 제목/메시지 본문 등)를 첨부해야합니다.

예제 코드 :

// 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[]{"[email protected]"}); 
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.")); 

나는이 도움이 희망! 체크 아웃하는 것 같아서

일부 소스 :
http://developer.android.com/guide/topics/intents/intents-filters.html
http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND

+0

도움을 주셔서 감사합니다. 내일 AM을 시도하고 결과를 게시합니다. – MADPADGE

+1

네, 도움이 되셨습니다! 귀하의 예를 들어 주셔서 감사합니다! – MADPADGE

1
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, someEditText.getText()); 
startActivity(Intent.createChooser(emailIntent, "Send someone an email...")); 
+0

도움을 주셔서 감사합니다. 오전입니다. 나는 그 결과로 답장 할 것이다. – MADPADGE

0

시도이

Intent intent = new Intent(Intent.ACTION_SENDTO); 
    intent.setData(Uri.parse("mailto:Type email address here")); 
    if (intent.resolveActivity(getPackageManager()) != null) { 
     startActivity(intent); 
    } 
+0

자세한 내용을 수정하십시오. 코드 전용 및 "시도하십시오"답변은 검색 가능한 콘텐츠가 없으므로 권장하지 않으며 누군가가 "시도해"야하는 이유를 설명하지 않습니다. – abarisone