Open Source • Background Tasks: Itoo 🚀

I need help with my program. I need to make an app that dims the screen based on the orientation on the phone. It needs to be able to do this in the foreground

I have tried to get it to read the orientation every half a second, but it always tells that the app keeps stoppping.