I have a form in a TableLayout
where the form is filled from my database, I want to send the table output via email.But I have problem with converting the tablelayout to Bitmap. Here is the final activity I am working on
public class SendEmail extends Activity {
Button buttonSend;
TableLayout tableMessage;
Intent emailFinal;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sendemail);
String Orderdate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
String email = pdatabase.getPEmail();
emailFinal = new Intent(Intent.ACTION_SEND);
emailFinal.putExtra(Intent.EXTRA_EMAIL, new String[]{ email});
buttonSend =(Button) findViewById(R.id.sendEmail);
tableMessage = (TableLayout) findViewById(R.id.tableLayout1);
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bitmap b = Bitmap.createBitmap( tableMessage.getWidth(),
tableMessage.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
tableMessage.draw(c);
BitmapDrawable d = new BitmapDrawable(getResources(), b)
emailFinal.putExtra(Intent.EXTRA_TEXT, b);
emailFinal.setType("message/rfc822");
startActivity(Intent.createChooser(emailFinal, "Choose an Email client :"));
}