Enable/disable power saving mode

I want to create an app that automatically activates power saving mode. Is there any function or extension to enable/disable power saving mode?

https://stackoverflow.com/questions/29367065/how-to-open-battery-saver-activity-in-android-l