2

上記のエラーメッセージに関する他の投稿を読みましたが、まだ存在する問題について説明したものはかなり前に回答としてマークされているため、別のスレッドで質問することをお勧めします-問題を解決するためのヒントは私にとってはうまくいきました。電話でアプリを実行すると問題が発生します。K9 メールと Google メールの両方がインストールされ、設定されています。

ここに私のコードスニペットがあります:

    final Intent imail = new Intent(Intent.ACTION_SENDTO);
    imail.setType("message/rfc822"); // or: text/plain
    imail.putExtra(Intent.EXTRA_EMAIL  , new String[]{"contact@mydomain.com"});
    imail.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
    imail.putExtra(Intent.EXTRA_TEXT   , emailText);
    try {
        startActivity(Intent.createChooser(imail, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(Feedback.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }

アプリは、電話に「このアクションを実行できるアプリケーションはありません」というエラーを表示します。

成功せずに試した別のバリエーションもあります。

    String mailId = (String) "contact@mydomain.com"; 
    final Intent imail = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( 
    "mailto",mailId, null)); 
    imail.setType("message/rfc822"); // text/plain
    imail.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
    imail.putExtra(Intent.EXTRA_TEXT, emailText);

    // Check if Intent available
    List<ResolveInfo> list = getPackageManager().queryIntentActivities(
            imail, PackageManager.MATCH_DEFAULT_ONLY);

この場合、上記のように K9 メールと Google メールがインストールされているにもかかわらず、List は Null のサイズを返します。私のシステムは HTC One V (Android 4) です

4

1 に答える 1

0

これを試して

 private void enviar(String[] to, String[] cc, String asunto, String mensaje)
{ 
        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.setData(Uri.parse("mailto:"));
        emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
        emailIntent.putExtra(Intent.EXTRA_CC, cc);
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, asunto);
        emailIntent.putExtra(Intent.EXTRA_TEXT, mensaje);
        emailIntent.setType("message/rfc822");

         startActivity(Intent.createChooser(emailIntent, "Email "));

}

これは Gmail で動作します

于 2013-09-11T10:00:28.817 に答える