ACTION_SEND force sending with email

前端 未结 9 1892
予麋鹿
予麋鹿 2021-02-15 11:37

every time i create an action for sending an email from my app, it prompts to many options including a QR client...

Is there a way to force sending via email clients onl

9条回答
  •  时光说笑
    2021-02-15 12:35

    It will show all the available app installed on android phone which can perform sharing or send a link from webview to others. Like - Gmail, facebook, imo, whatsapp, messenger etc.

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    String shareLink = webView.getUrl();
    intent.putExtra(Intent.EXTRA_TEXT, shareLink);
    startActivity(Intent.createChooser(intent, "Share via..."));
    

    But when you force to open mail app only :

    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"something@gmail.com"});
    
    try {
        startActivity(Intent.createChooser(intent, "send mail"));
    } catch (ActivityNotFoundException ex) {
        Toast.makeText(this, "No mail app found!!!", Toast.LENGTH_SHORT);
    } catch (Exception ex) {
        Toast.makeText(this, "Unexpected Error!!!", Toast.LENGTH_SHORT);
    }
    

提交回复
热议问题