So in the past, even on a previous Xperia Z2 (bought another after one got broken in an accident) I have tried to use Miracast but since the Android 6 update a couple years ago, the Miracast function doesn't work.
My only work around is to restart my phone and it works once. If I want it to work again, I have to restart it. It **bleep** that Sony stopped updating the Z2 but I understand why.
Has anyone had a permanent fix for this besides restarting every single time you want to use Miracast?