10

顧客にフィードバック機能を提供するアプリを作成しています。これを実現するために、ユーザーがフィードバックを入力してメール ID に送信できる小さなダイアログ ボックスを作成しました。インターネットで見つけたコード スニペットをいくつか試しましたが、エミュレーターまたは実際のデバイスから電子メールを送信しようとすると、「このアクションを実行できるアプリケーションはありません」というエラーが表示されます。

これが私のコードです:-

public void emailDialog()
{
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("Feedback");
    alertDialog.setMessage("Please tell us that what you feel about our product. If you are facing any problem or found any bug then please report to us. Your review is important to us. Thanks!!");
    final EditText input = new EditText(this);
    input.setLines(8);
    alertDialog.setView(input);
    alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            String address = "varundroid@gmail.com";
            String subject = "FeedBack";
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, address);
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, value);
            CompleteTaskManager.this.startActivity(Intent.createChooser(emailIntent, "Send Email.."));
        }
    });
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {
        // Canceled.
      }
    });
alertDialog.show();
}

助けてください。

4

2 に答える 2

18

I think you need to set the type of the intent object. Can you try the following

emailIntent.setType("message/rfc822");

or

emailIntent.setType("text/plain");
于 2011-04-25T14:21:41.440 に答える
0

誰かが XML 設定からこれを行おうとしている場合、アクションとして ACTION_SENDTO を、データとして mailto:your.email@domain.com を含むインテントを Preference 要素に追加することでこれを実現しました。これが誰かを助けることを願っています。

于 2014-08-12T15:06:58.527 に答える