0
Intent next = new Intent(Intent.ACTION_SENDTO);
next.setData(Uri.parse("mailto:zuron7@gmail.com"));
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);

When I run the app on my phone and hit the button which launches this method, it stops unexpectedly. I'm not really sure where the problem is. I basically want to take attendance for a group of students and send the names of those absent to the coordinator.

Mehraban
  • 3,164
  • 4
  • 37
  • 60
zuron7
  • 3
  • 1

1 Answers1

1

Maybe this will solve your problem: ACTION_SENDTO for sending an email

Basically you should try to pass your subject and message via the URI in setData.

Community
  • 1
  • 1
Sascha B
  • 640
  • 6
  • 10