the code in onReceive function
override fun onReceive(context: Context, intent: Intent) {
Log.i(“Receiver”, “This is broadcast receiver”)
Toast.makeText(context, “Language changed”, Toast.LENGTH_SHORT).show()
context.startActivity(Intent(context, MainActivity::class.java))
}
log message -
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at com.myapp.broadcastreceiverinkotlin.LocaleChangedReceiver.onReceive(LocaleChangedReceiver.kt:14)
app crashes when it tries to reopen MainActivity.kt