I'm building an app to handle anything that concerns the academic life of an university student, that is including his university mail account.
Let's say the phone where my app is installed has two or more different gmail account set:
- "account 1" - "abcdef@gmail.com"
- "account 2" - "123456@mydomain.com"
I know that to start the gmail app I could use this code:
public void showMailBox(View view){
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("plain/text");
sendIntent.setData(Uri.parse("test@gmail.com"));
sendIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "test@gmail.com" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "test");
sendIntent.putExtra(Intent.EXTRA_TEXT, "hello");
startActivity(sendIntent);
}
How could I set an intent to start Gmail, or Inbox, with the second account set as sender?