Skip to content

Instantly share code, notes, and snippets.

@fnzainal
Created November 23, 2016 02:57
Show Gist options
  • Save fnzainal/e2c8513e76da0849e259aa350fae3c9a to your computer and use it in GitHub Desktop.
Save fnzainal/e2c8513e76da0849e259aa350fae3c9a to your computer and use it in GitHub Desktop.
to start gmail with extra string
final Intent intentGmail = new Intent(Intent.ACTION_VIEW);
intentGmail.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
intentGmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "user@email.com" });
intentGmail.putExtra(Intent.EXTRA_SUBJECT, "SUBJECT EMAIL");
intentGmail.setType("plain/text");
intentGmail.putExtra(Intent.EXTRA_TEXT, "message email is here.."
);
try {
startActivity(intentGmail);
}catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(), getString(R.string.message_gmail_not_installed), Toast.LENGTH_SHORT).show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment