This is a follow up question to this question:
Force application to restart on first activity
I am trying to restart my application from a fragment like that:
Add this code as per your activity and your app will restart. This code is in kotlin.
val intent = Intent(baseContext, MainActivity::class.java)
val pendingIntentId = 101
val pendingIntent = PendingIntent.getActivity(this, pendingIntentId,intent, PendingIntent.FLAG_CANCEL_CURRENT)
val alarmManager = (this.getSystemService(Context.ALARM_SERVICE)) as AlarmManager
alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent)
exitProcess(0)