0

アプリにテキストボックス(EditText)とボタンがあります。ボタンをタップすると、テキストボックス(EditText)に書き込まれたテキストがコピーされ、このテキストを任意のアプリで共有できるようになります。 as-メッセージング、Gmail、Ymailなど。今私がしているのは、「EditText」からテキストを取得し、「a」と言う新しい変数(文字列)に保存して、インテント「ACTION_SEND_MULTIPLE」を適用することです。

これがインテントのコードです

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"example@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, a);
startActivity(Intent.createChooser(emailIntent, "Share it via..."));
4

2 に答える 2

0

あなたの問題が何であるかはわかりませんが、これは editText からテキストを取得する方法です

String mString= et.getText().toString();

次に、それを共有インテントに入れます

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, mString);
shareIntent.setType("text/plain");
startActivity(shareIntent);

メールとしてのみ送信し、メール クライアントのみがインテントに応答できるようにする場合は、次のようになります。

Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode("mail to address") 
   + "?subject=" + Uri.encode("subject here") 
   + "&body=" + Uri.encode("body here");
Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, "Send..."));   

これにより、件名フィールドとmailtoフィールドを入力できます...など

于 2013-03-16T13:02:25.930 に答える
0

おそらく「createChooser」が必要です:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, edittext.getText().toString());
startActivity(Intent.createChooser(intent, "chooser title"));
于 2013-03-16T13:11:40.910 に答える