新しい SMS を受信するたびにメイン アクティビティに警告するブロードキャスト レシーバーがあり、新しい SMS を受信するたびにアプリケーションがクラッシュします。
Logcat は次のように述べています。
10-14 15:56:03.465: E/AndroidRuntime(27068): FATAL EXCEPTION: main
10-14 15:56:03.465: E/AndroidRuntime(27068): java.lang.RuntimeException: Unable to start receiver com.testapp.SMSReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
エラーの原因と思われるレシーバーからのコードブロックを次に示します。
Intent passSMStoMain = new Intent(context, MainActivity.class);
passSMStoMain.putExtra("SENDER", msg_from);
passSMStoMain.putExtra("MESSAGE", msgBody);
context.startActivity(passSMStoMain);//this line makes the app crash
このエラーを修正するにはどうすればよいですか?