2014-03-07 35 views
0
Intent next = new Intent(Intent.ACTION_SENDTO); 
next.setData(Uri.parse("mailto:[email protected]")); 
next.putExtra(Intent.EXTRA_SUBJECT, "Attendance"); 
String message = ""; 
Resources r = getResources(); 
String name = getPackageName(); 
int[] ids = new int[3]; 
for(int i =0; i<3;i++){ 
    String x = "check"+i; 
    ids[i]= r.getIdentifier(x,"id", name); 
} 
for(int i = 0; i<3;i++){ 
    CheckBox checkbox = (CheckBox) findViewById(ids[i]); 
    if(checkbox.isChecked()){ 
     message=message+getResources().getString(R.string.Swag1); 
    } 
} 
next.putExtra(Intent.EXTRA_TEXT,message); 
if (next.resolveActivity(getPackageManager()) != null) 
    startActivity(next); 

当我在手机上运行应用程序并点击启动此方法的按钮时,它意外停止。我不确定问题出在哪里。我基本上想要参加一组学生,并将缺席的人员的姓名发送给协调员。检查检查列表中的元素是否打勾并通过电子邮件发送这些元素?

回答

1

也许这将解决您的问题:ACTION_SENDTO for sending an email

基本上你应该尝试通过URI中使用setData通过您的主题和消息。

+0

非常感谢。我在其中一本Android指南中找到了解决方案。 – zuron7

相关问题