0

I have a problem that I want in my application to have a specific email receiver whenever the user press the email button it shows to him/her a fixed receiver. How can I do this?

 public void google(View v){
       Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
       emailIntent.setType("plain/text");
       emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{});
       emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
       emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "");
       Intent shareIntent = Intent.createChooser(emailIntent,"");
       shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       startActivity(shareIntent);

 }

this is the code

this is the image of email

halfer
  • 19,824
  • 17
  • 99
  • 186
aak
  • 1
  • paste your code not image – Prajwal Waingankar Jan 17 '20 at 11:07
  • please see this link - https://stackoverflow.com/a/55843068/10989990 – Priyanka Jan 17 '20 at 11:10
  • What do you mean by email receiver? Are you trying to directly open a specific email application? If that is the case then you will need to know the package name for the specific email application you want and add it to the intent. For Example, if you want to open gmail then you can add `emailIntent.setPackage("com.google.android.gm")` – Rafsanjani Jan 17 '20 at 11:13
  • JavaScript and Java are two separate languages. Please remove the JavaScript tag. –  Jan 17 '20 at 11:13

1 Answers1

0

Use this code hope it will help

Intent Email = new Intent(Intent.ACTION_SEND);
            String[] recipents ={"your_recepient_email"};
            Email.putExtra(Intent.EXTRA_EMAIL,recipents);
            Email.setType("text/html")
            Email.setPackage("com.google.android.gm");
            startActivity(Intent.createChooser(Email, "Send mail"));

If you want subject and content use the code like how you added the lines for subject.