This app was mentioned in 3 comments, with an average of 1.33 upvotes
I use an app called Smartphone Addiction Timer (Android) and lock myself out of my phone for 45 minutes at a time. Then I take a 15 minute break.
I make sure I'm well fed but not overfull. A small amount of caffeine helps me, but not too much (I get sick). I have big noise blocking headphones (Sennheiser HD-280S) and I listen to ambient music (I used mostly classical for level 1 but find this stuff is better).
I found an android app that locks your phone for a set time. Its a little buggy but it really blocks everything
https://play.google.com/store/apps/details?id=jp.s122107.phonescreentimer