2011-04-08 15 views
0

나는 주 활동 활동을 시작하려고합니다. 이메일을 통해 데이터를 보내려고합니다. 하지만 코드를 실행하면 프로그램이 다운됩니다. 여기에 새로운 활동 시작의 내 코드는활동 내 활동 내역

Intent intent = new Intent(Intent.ACTION_SEND); 
    intent.setType("plain/html"); 
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]","[email protected]"}); 
    intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); 
    intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("my html text goes here")); 
    startActivity(intent); 
+1

로그 추적은 무엇인가? – rajath

+1

안녕하세요 [this] (http://www.anddev.org/email_send_intent_intentchooser-t3295.html) –

+0

[2011-04-08 12:53:13 - second_project] second_project.apk 설치 ... [2011-04 -08 12:53:24 - second_project] 성공! [2011-04-08 12:53:24 - second_project] 장치 에뮬레이터에서 활동 시작 com.second_project.geo_loc-5554 –

답변

1

과 같이 메일을 보내야하는 응용 프로그램을 찾을 수 Intent.createChooser 방법을 사용해보십시오 :

Intent emailIntent = new Intent(Intent.ACTION_SEND); 
    emailIntent.setType(EMAIL_CONTENT_TYPE); 

    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]","[email protected]"}); 
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject"); 
    emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("my html text goes here")); 

    Intent chooser = Intent.createChooser(emailIntent, "Choose the application to send the email"); 
    startActivity(chooser); 
+0

@ Flavio 나는 당신의 접근 방식을 시도했다. 하지만 여전히 작동하지 않습니다. 내 프로그램은 아직 실행 중이지만 아무 일도 일어나지 않습니다. 어떻게 메시지가 사라 졌는지 알 수 있습니까 ?? –

+0

이렇게하면 gmail과 같은 메일 응용 프로그램에 메시지를 전달할 수 있습니다. 그리고 gmail을 사용하면 메시지가 전송됩니다! 그래서 ... 당신은 Gmail이나 다른 메일 프로그램에 계정을 등록해야합니다. 그 후에 만 ​​Intent.createChooser가 모든 메일 프로그램을 찾아 메시지를 보낼 사람을 선택하도록 제안합니다. – Flavio

+1

안드로이드 메일 프로그램의 도움없이 직접 메시지를 보내려면 자바 메일 API를 사용해야합니다. – Flavio