Android - How to open the email client directly

前端 未结 2 1600
忘了有多久
忘了有多久 2020-12-16 05:18

I want to open the default email client instead of showing the options. I tried but i am not getting please can anyone help me.

I used the following code:

         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 05:55

    Frame a String in the format String URI="mailto:?subject=" + subject + "&body=" + body;

    and

    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri data = Uri.parse(URI);
    intent.setData(data);
    startActivity(intent);
    

    This will open up the default e-mail program selected by the user.

    Linkify does it this way. Check out it's source code, if you like.

提交回复
热议问题