Skip to content
Advertisement

I cant run the email intent code on my phone

enter image description here

the email intent code is completely run in the android mobile model provided by android studio but when I run the code in my personal phone its not work… please answer ??

Advertisement

Answer

Don’t forget to set the type of intent so it will trigger email clients

   Intent email = new Intent(Intent.ACTION_SEND);  
    email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});  
    email.putExtra(Intent.EXTRA_SUBJECT, subject);  
    email.putExtra(Intent.EXTRA_TEXT, message);  
           
    //need this to prompts email client only  
    email.setType("message/rfc822");  
      
    startActivity(Intent.createChooser(email, "Choose an Email client :"));

  
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement