を拡張するクラスから電子メールを送信する次のコードがありますBroadcastReceiver
。
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
S2Mconfig s2m = new S2Mconfig();
Log.d(TAG, "Create Intent for mail to " + address);
emailIntent.setType("plain/text");
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, s2m.read(thisContext));
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, address);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
Log.d(TAG, String.format("Sending mail %s", emailIntent.toString()));
thisContext.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
はBroadcastReciever
に登録されており、権限manifest
を設定しています。INTERNET
<uses-permission android:name="android.permission.INTERNET" />...
<receiver android:name=".SmsReceiver" android:exported="true" >
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.provider.Telephony.MMS_RECEIVED" />
</intent-filter>
</receiver>
FLAG_ACTIVITY_NEW_TASK
ログは、 への呼び出しの前に が設定されたことを確認しますstartActivity()
。これらすべてにもかかわらず、私はまだ恐ろしいものを手に入れます"Calling startActivity()... requires the FLAG_ACTIVITY_NEW_TASK flag...
。手がかりは大歓迎です。